static void UseSuccessCallback(MySyncControllableEntity sync, ref UseObject_UseMsg msg, MyNetworkClient sender) { MyEntity controlledEntity; if (MyEntities.TryGetEntityById <MyEntity>(msg.UsedByEntityId, out controlledEntity)) { var controllableEntity = controlledEntity as IMyControllableEntity; Debug.Assert(controllableEntity != null, "Controllable entity needs to get control from another controllable entity"); if (controllableEntity != null) { MyRelationsBetweenPlayerAndBlock relation = MyRelationsBetweenPlayerAndBlock.FactionShare; var cubeBlock = sync.Entity as MyCubeBlock; if (cubeBlock != null && controllableEntity.ControllerInfo.Controller != null) { relation = cubeBlock.GetUserRelationToOwner(controllableEntity.ControllerInfo.Controller.Player.Identity.IdentityId); } if (relation == MyRelationsBetweenPlayerAndBlock.FactionShare || relation == MyRelationsBetweenPlayerAndBlock.Owner) { sync.RaiseUseSuccess(msg.UseAction, controllableEntity); } else { sync.RaiseUseFailure(msg.UseAction, msg.UseResult, controllableEntity); } } } }
static void ShootDirectionChangeCallback(MySyncControllableEntity sync, ref ShootDirectionChangeMsg msg, MyNetworkClient sender) { sync.ShootDirection = msg.Direction; if (Sync.IsServer) { MySession.Static.SyncLayer.SendMessageToAllButOne(ref msg, sender.SteamUserId); } }
private static void OnSwitchAmmoMagazineFailure(MySyncControllableEntity sync, ref SwitchAmmoMagazineMsg msg, MyNetworkClient sender) { var handler = sync.SwitchAmmoMagazineFailureHandler; if (handler != null) { handler(); } }
static void ControlledEntity_UseCallback(MySyncControllableEntity sync, ref ControlledEntity_UseMsg msg, MyNetworkClient sender) { var handler = sync.ControlledEntity_Used; if (handler != null) { handler(); } }
private static void OnSwitchAmmoMagazineRequest(MySyncControllableEntity sync, ref SwitchAmmoMagazineMsg msg, MyNetworkClient sender) { if (!sync.Entity.CanSwitchAmmoMagazine()) { Sync.Layer.SendMessage(ref msg, sender.SteamUserId, MyTransportMessageEnum.Failure); return; } OnSwitchAmmoMagazineSuccess(sync, ref msg, Sync.Clients.LocalClient); Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success); }
static void UseFailureCallback(MySyncControllableEntity sync, ref UseObject_UseMsg msg, MyNetworkClient sender) { MyEntity controlledEntity; bool userFound = MyEntities.TryGetEntityById <MyEntity>(msg.UsedByEntityId, out controlledEntity); Debug.Assert(userFound); IMyControllableEntity controllableEntity = controlledEntity as IMyControllableEntity; Debug.Assert(controllableEntity != null, "Controllable entity needs to get control from another controllable entity"); sync.RaiseUseFailure(msg.UseAction, msg.UseResult, controllableEntity); }
static void ShootEndCallback(MySyncControllableEntity sync, ref ShootEndMsg msg, MyNetworkClient sender) { if (Sync.IsServer) { Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId); } bool wouldCallStopTwice = Sync.IsServer && sender.IsGameServer(); if (!wouldCallStopTwice) { sync.StopShooting(msg.Action); } }
private static void OnSwitchToWeaponFailure(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender) { if (!Sync.IsServer) { sync.m_switchWeaponCounter--; } var handler = sync.SwitchToWeaponFailureHandler; if (handler != null) { handler(msg.Weapon, msg.WeaponObjectBuilder, msg.WeaponEntityId); } }
private static void OnSwitchToWeaponRequest(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender) { if (!sync.Entity.CanSwitchToWeapon(msg.Weapon)) { Sync.Layer.SendMessage(ref msg, sender.SteamUserId, MyTransportMessageEnum.Failure); return; } // Allocate a new entity id for the new gun, if needed if (msg.WeaponObjectBuilder != null && msg.WeaponObjectBuilder.EntityId == 0) { msg.WeaponObjectBuilder = (MyObjectBuilder_EntityBase)msg.WeaponObjectBuilder.Clone(); msg.WeaponObjectBuilder.EntityId = msg.WeaponEntityId == 0 ? MyEntityIdentifier.AllocateId() : msg.WeaponEntityId; } OnSwitchToWeaponSuccess(sync, ref msg, Sync.Clients.LocalClient); Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success); }
private static void OnSwitchToWeaponSuccess(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender) { if (!Sync.IsServer) { // Update the counter only if we are waiting for it if (sync.m_switchWeaponCounter > 0) { sync.m_switchWeaponCounter--; } } var handler = sync.SwitchToWeaponSuccessHandler; if (handler != null) { handler(msg.Weapon, msg.WeaponObjectBuilder, msg.WeaponEntityId); } }
private static void OnSwitchAmmoMagazineSuccess(MySyncControllableEntity sync, ref SwitchAmmoMagazineMsg msg, MyNetworkClient sender) { if (!Sync.IsServer) { // Update the counter only if we are waiting for it if (sync.m_switchAmmoMagazineCounter > 0) { sync.m_switchAmmoMagazineCounter--; } } var handler = sync.SwitchAmmoMagazineSuccessHandler; if (handler != null) { handler(); } }
static void ControlledEntity_UseRequest(MySyncControllableEntity sync, ref ControlledEntity_UseMsg msg, MyNetworkClient sender) { // TODO: check responsibility for update ControlledEntity_UseCallback(sync, ref msg, sender); Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success); }
static void ShootDirectionChangeCallback(MySyncControllableEntity sync, ref ShootDirectionChangeMsg msg, MyNetworkClient sender) { sync.ShootDirection = msg.Direction; }
private static void OnSwitchAmmoMagazineSuccess(MySyncControllableEntity sync, ref SwitchAmmoMagazineMsg msg, MyNetworkClient sender) { if (!Sync.IsServer) { // Update the counter only if we are waiting for it if (sync.m_switchAmmoMagazineCounter > 0) { sync.m_switchAmmoMagazineCounter--; } } var handler = sync.SwitchAmmoMagazineSuccessHandler; if (handler != null) handler(); }
static void ControlledEntity_UseCallback(MySyncControllableEntity sync, ref ControlledEntity_UseMsg msg, MyNetworkClient sender) { var handler = sync.ControlledEntity_Used; if (handler != null) handler(); }
static void UseSuccessCallback(MySyncControllableEntity sync, ref UseObject_UseMsg msg, MyNetworkClient sender) { MyEntity controlledEntity; if (MyEntities.TryGetEntityById<MyEntity>(msg.UsedByEntityId, out controlledEntity)) { var controllableEntity = controlledEntity as IMyControllableEntity; Debug.Assert(controllableEntity != null, "Controllable entity needs to get control from another controllable entity"); if (controllableEntity != null) { MyRelationsBetweenPlayerAndBlock relation = MyRelationsBetweenPlayerAndBlock.NoOwnership; var cubeBlock = sync.Entity as MyCubeBlock; if (cubeBlock != null && controllableEntity.ControllerInfo.Controller != null) { relation = cubeBlock.GetUserRelationToOwner(controllableEntity.ControllerInfo.Controller.Player.Identity.IdentityId); } if (relation.IsFriendly()) { sync.RaiseUseSuccess(msg.UseAction, controllableEntity); } else { sync.RaiseUseFailure(msg.UseAction, msg.UseResult, controllableEntity); } } } }
private static void OnSwitchToWeaponRequest(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender) { if (!sync.Entity.CanSwitchToWeapon(msg.Weapon)) { Sync.Layer.SendMessage(ref msg, sender.SteamUserId, MyTransportMessageEnum.Failure); return; } // Allocate a new entity id for the new gun, if needed if (msg.WeaponObjectBuilder != null && msg.WeaponObjectBuilder.EntityId == 0) { msg.WeaponObjectBuilder = (MyObjectBuilder_EntityBase)msg.WeaponObjectBuilder.Clone(); msg.WeaponObjectBuilder.EntityId = msg.WeaponEntityId == 0 ? MyEntityIdentifier.AllocateId() : msg.WeaponEntityId; } OnSwitchToWeaponSuccess(sync, ref msg, Sync.Clients.LocalClient); Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success); }
private static void OnSwitchToWeaponSuccess(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender) { if (!Sync.IsServer) { // Update the counter only if we are waiting for it if (sync.m_switchWeaponCounter > 0) { sync.m_switchWeaponCounter--; } } var handler = sync.SwitchToWeaponSuccessHandler; if (handler != null) handler(msg.Weapon, msg.WeaponObjectBuilder, msg.WeaponEntityId); }
static void ShootEndCallback(MySyncControllableEntity sync, ref ShootEndMsg msg, MyNetworkClient sender) { if (Sync.IsServer) { Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId); } bool wouldCallStopTwice = Sync.IsServer && sender.IsGameServer(); if (!wouldCallStopTwice) sync.StopShooting(msg.Action); }
private static void OnSwitchAmmoMagazineFailure(MySyncControllableEntity sync, ref SwitchAmmoMagazineMsg msg, MyNetworkClient sender) { var handler = sync.SwitchAmmoMagazineFailureHandler; if (handler != null) handler(); }
private static void OnSwitchAmmoMagazineRequest(MySyncControllableEntity sync, ref SwitchAmmoMagazineMsg msg, MyNetworkClient sender) { if (!sync.Entity.CanSwitchAmmoMagazine()) { Sync.Layer.SendMessage(ref msg, sender.SteamUserId, MyTransportMessageEnum.Failure); return; } OnSwitchAmmoMagazineSuccess(sync, ref msg, Sync.Clients.LocalClient); Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success); }
private static void OnSwitchToWeaponFailure(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender) { if (!Sync.IsServer) { sync.m_switchWeaponCounter--; } var handler = sync.SwitchToWeaponFailureHandler; if (handler != null) handler(msg.Weapon, msg.WeaponObjectBuilder, msg.WeaponEntityId); }
static void ShootDirectionChangeCallback(MySyncControllableEntity sync, ref ShootDirectionChangeMsg msg, MyNetworkClient sender) { sync.ShootDirection = msg.Direction; if(Sync.IsServer) { MySession.Static.SyncLayer.SendMessageToAllButOne(ref msg, sender.SteamUserId); } }
static void UseFailureCallback(MySyncControllableEntity sync, ref UseObject_UseMsg msg, MyNetworkClient sender) { MyEntity controlledEntity; bool userFound = MyEntities.TryGetEntityById<MyEntity>(msg.UsedByEntityId, out controlledEntity); Debug.Assert(userFound); IMyControllableEntity controllableEntity = controlledEntity as IMyControllableEntity; Debug.Assert(controllableEntity != null, "Controllable entity needs to get control from another controllable entity"); sync.RaiseUseFailure(msg.UseAction, msg.UseResult, controllableEntity); }
static void ControlledEntity_UseRequest(MySyncControllableEntity sync, ref ControlledEntity_UseMsg msg, MyNetworkClient sender) { // TODO: check responsibility for update ControlledEntity_UseCallback(sync, ref msg, sender); Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success); }
static void ShootDirectionChangeCallback(MySyncControllableEntity sync, ref ShootDirectionChangeMsg msg, MyNetworkClient sender) { sync.ShootDirection = msg.Direction; }