-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from ari-steas/DoorDestroyer
Create DoorDestroyer
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |