internal void ResetShootState(ShootActions action, long playerId) { var cycleShootClick = Data.Repo.Base.State.TerminalAction == ShootActions.ShootClick && action == ShootActions.ShootClick; var cycleShootOn = Data.Repo.Base.State.TerminalAction == ShootActions.ShootOn && action == ShootActions.ShootOn; var cycleSomething = cycleShootOn || cycleShootClick; Data.Repo.Base.Set.Overrides.Control = GroupOverrides.ControlModes.Auto; Data.Repo.Base.State.TerminalActionSetter(this, cycleSomething ? ShootActions.ShootOff : action); if (action == ShootActions.ShootClick && HasTurret && !cycleShootClick) { Data.Repo.Base.State.Control = CompStateValues.ControlMode.Ui; } else if (action == ShootActions.ShootClick && !cycleShootClick || action == ShootActions.ShootOnce || action == ShootActions.ShootOn) { Data.Repo.Base.State.Control = CompStateValues.ControlMode.Toolbar; } else { Data.Repo.Base.State.Control = CompStateValues.ControlMode.None; } playerId = Session.HandlesInput && playerId == -1 ? Session.PlayerId : playerId; var noReset = !Data.Repo.Base.State.TrackingReticle; var newId = action == ShootActions.ShootOff && noReset ? -1 : playerId; Data.Repo.Base.State.PlayerId = newId; }
public void WeaponMode(WeaponComponent comp, ShootActions action, bool resetTerminalAction = true, bool syncCompState = true) { if (resetTerminalAction) { comp.Data.Repo.Base.State.TerminalAction = ShootActions.ShootOff; } Action = action; if (comp.Session.MpActive && comp.Session.IsServer && syncCompState) { comp.Session.SendCompState(comp); } }
public void TerminalActionSetter(WeaponComponent comp, ShootActions action, bool syncWeapons = false, bool updateWeapons = true) { TerminalAction = action; if (updateWeapons) { for (int i = 0; i < Weapons.Length; i++) { Weapons[i].Action = action; } } if (syncWeapons) { comp.Session.SendCompState(comp); } }
public void Sync(WeaponComponent comp, CompStateValues sync, Caller caller) { if (sync.Revision > Revision) { Revision = sync.Revision; TrackingReticle = sync.TrackingReticle; PlayerId = sync.PlayerId; Control = sync.Control; TerminalAction = sync.TerminalAction; for (int i = 0; i < sync.Weapons.Length; i++) { comp.Platform.Weapons[i].State.Sync(sync.Weapons[i]); } } //else Log.Line($"CompStateValues older revision: {sync.Revision} > {Revision} - caller:{caller}"); }
public bool Sync(WeaponComponent comp, CompStateValues sync, Caller caller) { if (sync.Revision > Revision || caller == Caller.CompData) { Revision = sync.Revision; TrackingReticle = sync.TrackingReticle; PlayerId = sync.PlayerId; Control = sync.Control; TerminalAction = sync.TerminalAction; for (int i = 0; i < sync.Weapons.Length; i++) { comp.Platform.Weapons[i].State.Sync(sync.Weapons[i]); } return(true); } return(false); }
internal void SendActionShootUpdate(WeaponComponent comp, ShootActions action) { if (IsClient) { uint[] mIds; if (PlayerMIds.TryGetValue(MultiplayerId, out mIds)) { comp.Session.PacketsToServer.Add(new ShootStatePacket { MId = ++mIds[(int)PacketType.RequestShootUpdate], EntityId = comp.MyCube.EntityId, SenderId = comp.Session.MultiplayerId, PType = PacketType.RequestShootUpdate, Action = action, PlayerId = PlayerId, }); } else { Log.Line($"SendActionShootUpdate no player MIds found"); } } else if (HandlesInput) { PacketsToClient.Add(new PacketInfo { Entity = comp.MyCube, Packet = new ShootStatePacket { MId = ++comp.MIds[(int)PacketType.RequestShootUpdate], EntityId = comp.MyCube.EntityId, SenderId = comp.Session.MultiplayerId, PType = PacketType.RequestShootUpdate, Action = action, PlayerId = PlayerId, } }); } else { Log.Line($"SendActionShootUpdate should never be called on Dedicated"); } }
internal void RequestShootUpdate(ShootActions action, long playerId) { if (IsDisabled) { return; } if (Session.HandlesInput) { Session.TerminalMon.HandleInputUpdate(this); } if (Session.IsServer) { ResetShootState(action, playerId); if (action == ShootActions.ShootOnce) { ShootOnceCheck(); } if (Session.MpActive) { Session.SendCompBaseData(this); if (action == ShootActions.ShootClick || action == ShootActions.ShootOn) { foreach (var w in Platform.Weapons) { Session.SendWeaponAmmoData(w); } } } } else if (action == ShootActions.ShootOnce) { ShootOnceCheck(); } else { Session.SendActionShootUpdate(this, action); } }
public override void CleanUp() { base.CleanUp(); Action = ShootActions.ShootOff; PlayerId = -1; }
[ProtoMember(3), DefaultValue(ShootActions.ShootOff)] public ShootActions Action = ShootActions.ShootOff; // save public void Sync(WeaponStateValues sync) { Heat = sync.Heat; Overheated = sync.Overheated; Action = sync.Action; }