Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 7607ed3

Browse files
committed
Update for SE v172. Fix drill speed thing
1 parent 3c1c73d commit 7607ed3

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//410
1+
//415
22
//
33
// This code was generated by a tool. Any changes made manually will be lost
44
// the next time this code is regenerated.
55
//
66

77
using System.Reflection;
88

9-
[assembly: AssemblyFileVersion("1.13.7.410")]
10-
[assembly: AssemblyVersion("1.13.7.410")]
9+
[assembly: AssemblyFileVersion("1.13.7.415")]
10+
[assembly: AssemblyVersion("1.13.7.415")]

EssentialsPlugin/Essentials.cs

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
using SEModAPI.API.Utility;
2929
using SEModAPI.API;
3030
using SEModAPIExtensions.API;
31-
using SEModAPIExtensions.API.Plugin;
3231
using SEModAPIExtensions.API.Plugin.Events;
3332
using SEModAPIInternal.API.Common;
3433
using SEModAPIInternal.API.Entity.Sector.SectorObject;
@@ -49,8 +48,10 @@
4948
using VRage.Game.Entity;
5049
using VRage.Library.Collections;
5150
using VRage.Network;
51+
using VRage.Plugins;
5252
using VRage.Serialization;
5353
using VRageMath;
54+
using IPlugin = SEModAPIExtensions.API.Plugin.IPlugin;
5455

5556
public class Essentials : IPlugin, IChatEventHandler, IPlayerEventHandler, ICubeGridHandler, ICubeBlockEventHandler, ISectorEventHandler
5657
{
@@ -1316,9 +1317,11 @@ private void DoInit( string path )
13161317
MyAPIGateway.Multiplayer.RegisterMessageHandler(9005, Communication.ReceiveMessageParts);
13171318
MyAPIGateway.Multiplayer.RegisterMessageHandler( 9007, Communication.HandleAddConcealExempt );
13181319
BlacklistManager.Instance.UpdateBlacklist();
1319-
//_drillUpdateVal= (int)typeof(MyDrillConstants).GetField("DRILL_UPDATE_INTERVAL_IN_FRAMES").GetValue(null);
1320-
//m_entitiesForUpdate10 = (CachingList<MyEntity>)typeof(MyEntities).GetField("m_entitiesForUpdate10", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
1321-
//_countdownField = typeof(MyShipDrill).GetField("m_drillFrameCountdown", BindingFlags.NonPublic | BindingFlags.Instance);
1320+
_drillUpdateVal= (int)typeof(MyDrillConstants).GetField("DRILL_UPDATE_INTERVAL_IN_FRAMES").GetValue(null);
1321+
m_entitiesForUpdate10 = ((MyDistributedUpdater<CachingList<MyEntity>, MyEntity>)typeof(MyEntities).GetField("m_entitiesForUpdate10", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)).List;
1322+
_countdownField = typeof(MyShipDrill).GetField("m_drillFrameCountdown", BindingFlags.NonPublic | BindingFlags.Instance);
1323+
var pluginslist = (List<VRage.Plugins.IPlugin>)typeof(MyPlugins).GetField("m_plugins", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
1324+
pluginslist.Add( new FakeVRagePlugin( ) );
13221325
Log.Info( "Plugin '{0}' initialized. (Version: {1} ID: {2})", Name, Version, Id );
13231326
}
13241327

@@ -1452,9 +1455,9 @@ public void Shutdown( )
14521455
}
14531456

14541457
//private int _updateCounter;
1455-
//private int _drillUpdateVal;
1456-
//static CachingList<MyEntity> m_entitiesForUpdate10;
1457-
//private FieldInfo _countdownField;
1458+
private int _drillUpdateVal;
1459+
static CachingList<MyEntity> m_entitiesForUpdate10;
1460+
private FieldInfo _countdownField;
14581461

14591462
public void Update( )
14601463
{
@@ -1483,6 +1486,31 @@ public void Update( )
14831486

14841487
#endregion
14851488

1489+
public void GameUpdate()
1490+
{
1491+
if (MyAPIGateway.Session == null)
1492+
return;
1493+
1494+
//if (++_updateCounter % 10 != 0)
1495+
// return;
1496+
1497+
1498+
//Wrapper.BeginGameAction(() =>
1499+
//{
1500+
//foreach (var entity in m_entitiesForUpdate10)
1501+
for (int i = 0; i < m_entitiesForUpdate10.Count; i++)
1502+
{
1503+
var entity = m_entitiesForUpdate10[i];
1504+
if (!(entity is MyShipDrill))
1505+
continue;
1506+
//Log.Debug( "Update " + entity.DisplayName );
1507+
int val = (int)_countdownField.GetValue(entity);
1508+
val -= PluginSettings.Instance.DrillSpeed / 10;
1509+
_countdownField.SetValue(entity, val);
1510+
}
1511+
//}, null, null);
1512+
}
1513+
14861514
#region IChatEventHandler Members
14871515

14881516
public void OnMessageReceived( )
@@ -1731,5 +1759,22 @@ public Version Version
17311759
}
17321760

17331761
#endregion
1762+
17341763
}
1764+
1765+
class FakeVRagePlugin : VRage.Plugins.IPlugin
1766+
{
1767+
public void Dispose( )
1768+
{
1769+
}
1770+
1771+
public void Init( object gameInstance )
1772+
{
1773+
}
1774+
1775+
public void Update( )
1776+
{
1777+
Essentials.Instance.GameUpdate( );
1778+
}
1779+
}
17351780
}

0 commit comments

Comments
 (0)