forked from StarCoreSE/Orrery-Combat-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
n_MagazineUpdate, n_TargetingUpdate, and HeartNetwork.SendToEveryoneI…
…nSync
- Loading branch information
Showing
11 changed files
with
163 additions
and
30 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
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
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
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
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
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
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
33 changes: 33 additions & 0 deletions
33
...ework - Heart Module/Data/Scripts/HeartModule/Weapons/StandardClasses/n_MagazineUpdate.cs
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,33 @@ | ||
using Heart_Module.Data.Scripts.HeartModule.ExceptionHandler; | ||
using Heart_Module.Data.Scripts.HeartModule.Network; | ||
using ProtoBuf; | ||
using System; | ||
|
||
namespace Heart_Module.Data.Scripts.HeartModule.Weapons.StandardClasses | ||
{ | ||
/// <summary> | ||
/// Triggered whenever a weapon's magazine is emptied by the server. | ||
/// </summary> | ||
[ProtoContract] | ||
internal class n_MagazineUpdate : PacketBase | ||
{ | ||
[ProtoMember(1)] internal long WeaponEntityId; | ||
[ProtoMember(2)] internal int MillisecondsFromMidnight; | ||
[ProtoMember(3)] internal int MagazinesLoaded; | ||
|
||
public override void Received(ulong SenderSteamId) | ||
{ | ||
var magazine = WeaponManager.I.GetWeapon(WeaponEntityId)?.Magazines; | ||
if (magazine == null) | ||
return; | ||
|
||
float timeDelta = (float) ((DateTime.UtcNow.TimeOfDay.TotalMilliseconds - MillisecondsFromMidnight)/1000); | ||
|
||
magazine.EmptyMagazines(); | ||
magazine.MagazinesLoaded = MagazinesLoaded; | ||
magazine.UpdateReload(timeDelta); | ||
|
||
HeartLog.Log($"Magazine updated for weapon {WeaponEntityId}! Delta: " + timeDelta); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...work - Heart Module/Data/Scripts/HeartModule/Weapons/StandardClasses/n_TargetingUpdate.cs
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,43 @@ | ||
using Heart_Module.Data.Scripts.HeartModule.Network; | ||
using Heart_Module.Data.Scripts.HeartModule.Weapons.AiTargeting; | ||
using ProtoBuf; | ||
using Sandbox.ModAPI; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using VRage.Game.ModAPI; | ||
using VRage.ModAPI; | ||
using YourName.ModName.Data.Scripts.HeartModule.Weapons.Setup.Adding; | ||
|
||
namespace Heart_Module.Data.Scripts.HeartModule.Weapons.StandardClasses | ||
{ | ||
// TODO complete | ||
[ProtoContract] | ||
internal class n_TargetingUpdate : PacketBase | ||
{ | ||
[ProtoMember(1)] long EntityId; | ||
[ProtoMember(2)] long TargetEntityId; | ||
|
||
public override void Received(ulong SenderSteamId) | ||
{ | ||
IMyEntity thisEntity = MyAPIGateway.Entities.GetEntityById(EntityId); | ||
if (thisEntity == null) | ||
return; | ||
|
||
IMyEntity targetEntity = MyAPIGateway.Entities.GetEntityById(TargetEntityId); | ||
|
||
if (thisEntity is IMyCubeGrid) | ||
{ | ||
WeaponManagerAi.I.GetTargeting((IMyCubeGrid) thisEntity).SetPrimaryTarget((IMyCubeGrid) targetEntity); | ||
} | ||
else if (thisEntity is IMyConveyorSorter) | ||
{ | ||
SorterTurretLogic weapon = WeaponManager.I.GetWeapon(EntityId) as SorterTurretLogic; | ||
|
||
weapon?.SetTarget(targetEntity); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.