Skip to content

Commit

Permalink
Merge pull request #276 from ari-steas/DoorDestroyer
Browse files Browse the repository at this point in the history
Create DoorDestroyer
  • Loading branch information
ari-steas authored Dec 6, 2024
2 parents db35c92 + 4794c1b commit d837821
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
47 changes: 47 additions & 0 deletions DoorDestroyer/Data/Scripts/DoorDestroyer/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Sandbox.Common.ObjectBuilders;
using Sandbox.ModAPI;
using VRage.Game.Components;
using VRage.Game.Entity;
using VRage.Game.ModAPI;
using VRage.ModAPI;
using VRage.ObjectBuilders;

// ReSharper disable UnusedType.Global
namespace TSTSSES.DoorDestroyer
{
[MyEntityComponentDescriptor(typeof(MyObjectBuilder_Door), false)]
internal class DoorDestroyer : GenericDoorDestroyer<IMyDoor> { }

[MyEntityComponentDescriptor(typeof(MyObjectBuilder_AirtightSlideDoor), false)]
internal class SlideGenericDoorDestroyer : GenericDoorDestroyer<IMyAirtightSlideDoor> { }

[MyEntityComponentDescriptor(typeof(MyObjectBuilder_AirtightHangarDoor), false)]
internal class HangarGenericDoorDestroyer : GenericDoorDestroyer<IMyAirtightHangarDoor> { }

[MyEntityComponentDescriptor(typeof(MyObjectBuilder_AdvancedDoor), false)]
internal class AdvancedGenericDoorDestroyer : GenericDoorDestroyer<IMyAdvancedDoor> { }

internal class GenericDoorDestroyer<T> : MyGameLogicComponent where T : IMyCubeBlock
{
private T _door;

public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
base.Init(objectBuilder);
NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
}

public override void UpdateOnceBeforeFrame()
{
base.UpdateOnceBeforeFrame();

_door = (T) Entity;
if(_door?.CubeGrid?.Physics == null || !(_door is MyEntity))
return;

foreach (var part in (_door as MyEntity).Subparts.Values)
if (part.Physics != null)
part.Physics.Enabled = false;
}
}
}
3 changes: 3 additions & 0 deletions DoorDestroyer/DoorDestroyer.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=data/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=data_005Cscripts/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 comments on commit d837821

Please sign in to comment.