diff --git a/Libraries/SEModAPI.dll b/Libraries/SEModAPI.dll index 364c6b5..1794188 100644 Binary files a/Libraries/SEModAPI.dll and b/Libraries/SEModAPI.dll differ diff --git a/Libraries/SEModAPIExtensions.dll b/Libraries/SEModAPIExtensions.dll index 8214aba..6c8a402 100644 Binary files a/Libraries/SEModAPIExtensions.dll and b/Libraries/SEModAPIExtensions.dll differ diff --git a/Libraries/SEModAPIInternal.dll b/Libraries/SEModAPIInternal.dll index 0e072ff..649b5fa 100644 Binary files a/Libraries/SEModAPIInternal.dll and b/Libraries/SEModAPIInternal.dll differ diff --git a/Libraries/Sandbox.Common.XmlSerializers.dll b/Libraries/Sandbox.Common.XmlSerializers.dll index 3a8f68f..1109977 100644 Binary files a/Libraries/Sandbox.Common.XmlSerializers.dll and b/Libraries/Sandbox.Common.XmlSerializers.dll differ diff --git a/Libraries/Sandbox.Common.dll b/Libraries/Sandbox.Common.dll index 70c3142..e69506c 100644 Binary files a/Libraries/Sandbox.Common.dll and b/Libraries/Sandbox.Common.dll differ diff --git a/Libraries/VRage.Common.dll b/Libraries/VRage.Common.dll index 8b81fd4..2eedc0f 100644 Binary files a/Libraries/VRage.Common.dll and b/Libraries/VRage.Common.dll differ diff --git a/Libraries/VRage.Math.dll b/Libraries/VRage.Math.dll index c8f4e86..61e5140 100644 Binary files a/Libraries/VRage.Math.dll and b/Libraries/VRage.Math.dll differ diff --git a/ReactorRadiationPlugin/Core.cs b/ReactorRadiationPlugin/Core.cs index 4eb8a0b..4c63153 100644 --- a/ReactorRadiationPlugin/Core.cs +++ b/ReactorRadiationPlugin/Core.cs @@ -35,6 +35,7 @@ public class Core : PluginBase, ICubeBlockEventHandler protected TimeSpan m_timeSinceLastUpdate; protected DateTime m_lastUpdate; protected DateTime m_lastFullScan; + protected DateTime m_lastRadiationDamage; #endregion @@ -46,11 +47,12 @@ public Core() m_isActive = false; - m_radiationRange = 10; + m_radiationRange = 5; m_damageRate = 1; m_lastUpdate = DateTime.Now; m_lastFullScan = DateTime.Now; + m_lastRadiationDamage = DateTime.Now; m_timeSinceLastUpdate = DateTime.Now - m_lastUpdate; } @@ -107,11 +109,19 @@ public override void Update() m_timeSinceLastUpdate = DateTime.Now - m_lastUpdate; m_lastUpdate = DateTime.Now; - foreach (var entry in m_reactorMap) + TimeSpan timeSinceLastRadiation = DateTime.Now - m_lastRadiationDamage; + if (timeSinceLastRadiation.TotalMilliseconds > 1000) { - foreach (ReactorEntity reactor in entry.Value) + m_lastRadiationDamage = DateTime.Now; + + List characters = SectorObjectManager.Instance.GetTypedInternalData(); + + foreach (var entry in m_reactorMap) { - DoRadiationDamage(reactor); + foreach (ReactorEntity reactor in entry.Value) + { + DoRadiationDamage(characters, reactor); + } } } @@ -241,7 +251,7 @@ private void FullScan() } } - private void DoRadiationDamage(ReactorEntity source) + private void DoRadiationDamage(List targets, ReactorEntity source) { if (source == null) return; @@ -250,23 +260,19 @@ private void DoRadiationDamage(ReactorEntity source) if (!source.Enabled) return; - List characters = SectorObjectManager.Instance.GetTypedInternalData(); - - //TODO - Check if this is accurate at all for calculating the beacon's actual location - //The parent's position might not be at cubegrid 0,0,0 and might be at center of mass which is going to be hard to calculate - Vector3I beaconBlockPos = source.Min; + Vector3I blockGridPos = source.Min; Matrix matrix = source.Parent.PositionAndOrientation.GetMatrix(); Matrix orientation = matrix.GetOrientation(); - Vector3 rotatedBlockPos = Vector3.Transform((Vector3)beaconBlockPos * 2.5f, orientation); - Vector3 beaconPos = rotatedBlockPos + source.Parent.Position; + Vector3 rotatedBlockPos = Vector3.Transform((Vector3)blockGridPos * 2.5f, orientation); + Vector3 reactorPos = rotatedBlockPos + source.Parent.Position; - foreach (CharacterEntity character in characters) + foreach (CharacterEntity character in targets) { - double distance = Vector3.Distance(character.Position, beaconPos); - if (distance < _RadiationRange) + double distance = Vector3.Distance(character.Position, reactorPos); + double range = 0.05 * source.Power * _RadiationRange; + if (distance < range) { - //TODO - Scale the damage based on the current power output of the reactor - double damage = _DamageRate * m_timeSinceLastUpdate.TotalSeconds * (_RadiationRange - distance); + double damage = _DamageRate * m_timeSinceLastUpdate.TotalSeconds * (range - distance); character.Health = character.Health - (float)damage; } } diff --git a/ReactorRadiationPlugin/Properties/AssemblyInfo.cs b/ReactorRadiationPlugin/Properties/AssemblyInfo.cs index 685828b..94e42f1 100644 --- a/ReactorRadiationPlugin/Properties/AssemblyInfo.cs +++ b/ReactorRadiationPlugin/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.1.0")] +[assembly: AssemblyFileVersion("0.1.1.0")]