Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace midspace
- {
- using Sandbox.Common;
- using Sandbox.Common.Components;
- using Sandbox.Common.ObjectBuilders;
- using Sandbox.ModAPI;
- using VRage.Components;
- using VRage.ModAPI;
- using VRage.ObjectBuilders;
- using VRageMath;
- /// <summary>
- /// This will prevent anyone from building anything.
- /// Tested in creative and survival mode.
- /// Tested in single player and dedicated server.
- ///
- /// Only issue is, sometimes the build block appears for a moment when switching between nothing and a build block.
- /// Have not been able to build/destroy anything during that small moment, so it seems stable.
- ///
- /// Recommend turning off Copy and Paste at the same time complete the effect.
- ///
- /// This is suitable for game scenarios where you want players to compete in something but not have access to building anything.
- /// Another method for achieving this would be to remove all buildable cubes from the game menu,
- /// but they may require a tailored mod depending on how many other modded cubes are loaded.
- /// </summary>
- /// <permission cref="midspace. Use however you want." />
- [MyEntityComponentDescriptor(typeof(MyObjectBuilder_CubePlacer))]
- public class MyBuildBlockerLogic : MyGameLogicComponent
- {
- private MyObjectBuilder_EntityBase _objectBuilder;
- public override void Close()
- {
- }
- public override void Init(MyObjectBuilder_EntityBase objectBuilder)
- {
- _objectBuilder = objectBuilder;
- Entity.NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
- if (MyAPIGateway.CubeBuilder != null)
- {
- MyAPIGateway.CubeBuilder.DeactivateBlockCreation();
- MyAPIGateway.CubeBuilder.Deactivate();
- }
- }
- public override void MarkForClose()
- {
- }
- public override void UpdateAfterSimulation()
- {
- if (MyAPIGateway.CubeBuilder != null)
- {
- MyAPIGateway.CubeBuilder.DeactivateBlockCreation();
- MyAPIGateway.CubeBuilder.Deactivate();
- }
- }
- public override void UpdateAfterSimulation10()
- {
- }
- public override void UpdateAfterSimulation100()
- {
- }
- public override void UpdateBeforeSimulation()
- {
- if (MyAPIGateway.CubeBuilder != null)
- {
- MyAPIGateway.CubeBuilder.DeactivateBlockCreation();
- MyAPIGateway.CubeBuilder.Deactivate();
- }
- }
- public override void UpdateBeforeSimulation10()
- {
- }
- public override void UpdateBeforeSimulation100()
- {
- if (MyAPIGateway.Utilities != null)
- {
- MyAPIGateway.Utilities.ShowNotification("Building is Disabled.", 1000, MyFontEnum.Blue);
- }
- if (MyAPIGateway.CubeBuilder != null)
- {
- MyAPIGateway.CubeBuilder.DeactivateBlockCreation();
- MyAPIGateway.CubeBuilder.Deactivate();
- }
- }
- public override void UpdateOnceBeforeFrame()
- {
- if (MyAPIGateway.CubeBuilder != null)
- {
- MyAPIGateway.CubeBuilder.DeactivateBlockCreation();
- MyAPIGateway.CubeBuilder.Deactivate();
- }
- }
- public override MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
- {
- return copy ? Entity.GetObjectBuilder() : _objectBuilder;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement