From ccc215b42de8bf6b8c544fefd1829706be97387a Mon Sep 17 00:00:00 2001 From: fabricator77 Date: Fri, 29 Apr 2016 22:45:31 +0930 Subject: [PATCH 1/3] Allow modAPI (script) access to OnGridChanged events. OnGridChanged is used in the cargoship code to detect when a Player has taken over a ship so it doesn't despawn. It's not possible to create the same functionality with other available events, which can be triggered by things like minor damage to ships, or unpowered ships drifting. --- Sources/Sandbox.Game/ModAPI/Blocks/MyCubeGrid_ModAPI.cs | 6 ++++++ Sources/VRage.Game/ModAPI/IMyCubeGrid.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/Sources/Sandbox.Game/ModAPI/Blocks/MyCubeGrid_ModAPI.cs b/Sources/Sandbox.Game/ModAPI/Blocks/MyCubeGrid_ModAPI.cs index 6ce346408a..2b131c5abc 100644 --- a/Sources/Sandbox.Game/ModAPI/Blocks/MyCubeGrid_ModAPI.cs +++ b/Sources/Sandbox.Game/ModAPI/Blocks/MyCubeGrid_ModAPI.cs @@ -247,6 +247,12 @@ event Action IMyCubeGrid.OnBlockOwnershipChanged remove { OnBlockOwnershipChanged -= GetDelegate(value); } } + event Action IMyCubeGrid.OnGridChanged + { + add { OnGridChanged += GetDelegate(value); } + remove { OnGridChanged -= GetDelegate(value); } + } + VRage.Game.ModAPI.Ingame.IMySlimBlock VRage.Game.ModAPI.Ingame.IMyCubeGrid.GetCubeBlock(Vector3I position) { VRage.Game.ModAPI.Ingame.IMySlimBlock block = GetCubeBlock(position); diff --git a/Sources/VRage.Game/ModAPI/IMyCubeGrid.cs b/Sources/VRage.Game/ModAPI/IMyCubeGrid.cs index 2bf0a3a105..a60a8aba61 100644 --- a/Sources/VRage.Game/ModAPI/IMyCubeGrid.cs +++ b/Sources/VRage.Game/ModAPI/IMyCubeGrid.cs @@ -241,6 +241,7 @@ public interface IMyCubeGrid : IMyEntity, Ingame.IMyCubeGrid event Action OnBlockAdded; event Action OnBlockRemoved; event Action OnBlockOwnershipChanged; + event Action OnGridChanged; void UpdateOwnership(long ownerId, bool isFunctional); VRageMath.Vector3I WorldToGridInteger(VRageMath.Vector3D coords); From 4f36ab819679c0bcae35598b67430d455cbf34dd Mon Sep 17 00:00:00 2001 From: fabricator77 Date: Tue, 3 May 2016 18:05:39 +0930 Subject: [PATCH 2/3] expose CreateNewNpcIdentity exposes CreateNewNpcIdentity to IMyPlayerCollection IMyIdentity IMyPlayerCollection.CreateNewNpcIdentity(string name) Note this can only be used to create NPCs, not faked players. --- Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs | 5 +++++ Sources/VRage.Game/ModAPI/IMyPlayerCollection.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs b/Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs index c0a826879d..01f47cd97e 100644 --- a/Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs +++ b/Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs @@ -111,5 +111,10 @@ void IMyPlayerCollection.GetAllIdentites(List identities, Func identities, Func collect = null); + IMyIdentity CreateNewNpcIdentity(string name); //void WriteDebugInfo(); } } From 445125f0cd698f1e26c80596e37605d9c60ca959 Mon Sep 17 00:00:00 2001 From: fabricator77 Date: Wed, 4 May 2016 09:16:36 +0930 Subject: [PATCH 3/3] Revert "expose CreateNewNpcIdentity" This reverts commit 4f36ab819679c0bcae35598b67430d455cbf34dd. --- Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs | 5 ----- Sources/VRage.Game/ModAPI/IMyPlayerCollection.cs | 1 - 2 files changed, 6 deletions(-) diff --git a/Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs b/Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs index 01f47cd97e..c0a826879d 100644 --- a/Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs +++ b/Sources/Sandbox.Game/ModAPI/MyPlayerCollection_ModAPI.cs @@ -111,10 +111,5 @@ void IMyPlayerCollection.GetAllIdentites(List identities, Func identities, Func collect = null); - IMyIdentity CreateNewNpcIdentity(string name); //void WriteDebugInfo(); } }