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

Commit

Permalink
Update for SE v172. Fix drill speed thing
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxar-tc committed Jan 28, 2017
1 parent 3c1c73d commit 7607ed3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 10 deletions.
6 changes: 3 additions & 3 deletions EssentialsPlugin/AssemblyFileVersion.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//410
//415
//
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
//

using System.Reflection;

[assembly: AssemblyFileVersion("1.13.7.410")]
[assembly: AssemblyVersion("1.13.7.410")]
[assembly: AssemblyFileVersion("1.13.7.415")]
[assembly: AssemblyVersion("1.13.7.415")]
59 changes: 52 additions & 7 deletions EssentialsPlugin/Essentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
using SEModAPI.API.Utility;
using SEModAPI.API;
using SEModAPIExtensions.API;
using SEModAPIExtensions.API.Plugin;
using SEModAPIExtensions.API.Plugin.Events;
using SEModAPIInternal.API.Common;
using SEModAPIInternal.API.Entity.Sector.SectorObject;
Expand All @@ -49,8 +48,10 @@
using VRage.Game.Entity;
using VRage.Library.Collections;
using VRage.Network;
using VRage.Plugins;
using VRage.Serialization;
using VRageMath;
using IPlugin = SEModAPIExtensions.API.Plugin.IPlugin;

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

Expand Down Expand Up @@ -1452,9 +1455,9 @@ public void Shutdown( )
}

//private int _updateCounter;
//private int _drillUpdateVal;
//static CachingList<MyEntity> m_entitiesForUpdate10;
//private FieldInfo _countdownField;
private int _drillUpdateVal;
static CachingList<MyEntity> m_entitiesForUpdate10;
private FieldInfo _countdownField;

public void Update( )
{
Expand Down Expand Up @@ -1483,6 +1486,31 @@ public void Update( )

#endregion

public void GameUpdate()
{
if (MyAPIGateway.Session == null)
return;

//if (++_updateCounter % 10 != 0)
// return;


//Wrapper.BeginGameAction(() =>
//{
//foreach (var entity in m_entitiesForUpdate10)
for (int i = 0; i < m_entitiesForUpdate10.Count; i++)
{
var entity = m_entitiesForUpdate10[i];
if (!(entity is MyShipDrill))
continue;
//Log.Debug( "Update " + entity.DisplayName );
int val = (int)_countdownField.GetValue(entity);
val -= PluginSettings.Instance.DrillSpeed / 10;
_countdownField.SetValue(entity, val);
}
//}, null, null);
}

#region IChatEventHandler Members

public void OnMessageReceived( )
Expand Down Expand Up @@ -1731,5 +1759,22 @@ public Version Version
}

#endregion

}

class FakeVRagePlugin : VRage.Plugins.IPlugin
{
public void Dispose( )
{
}

public void Init( object gameInstance )
{
}

public void Update( )
{
Essentials.Instance.GameUpdate( );
}
}
}

0 comments on commit 7607ed3

Please sign in to comment.