/// <summary> /// /// </summary> public static void SyncBlockDataRequestSend(NanobotBuildAndRepairSystemBlock block) { if (MyAPIGateway.Session.IsServer) { return; } var msgSnd = new MsgBlockDataRequest(); if (MyAPIGateway.Session.Player != null) { msgSnd.SteamId = MyAPIGateway.Session.Player.SteamUserId; } else { msgSnd.SteamId = 0; } msgSnd.EntityId = block.Entity.EntityId; if (Mod.Log.ShouldLog(Logging.Level.Communication)) { Mod.Log.Write(Logging.Level.Communication, "BuildAndRepairSystemMod: SyncBlockDataRequestSend SteamId={0} EntityId={1}/{2}", msgSnd.SteamId, msgSnd.EntityId, Logging.BlockName(block.Entity, Logging.BlockNameOptions.None)); } MyAPIGateway.Multiplayer.SendMessageToServer(MSGID_BLOCK_DATAREQUEST, MyAPIGateway.Utilities.SerializeToBinary(msgSnd), true); }
/// <summary> /// /// </summary> public static void SyncBlockSettingsSend(ulong steamId, NanobotBuildAndRepairSystemBlock block) { if (!MyAPIGateway.Utilities.IsDedicated && MyAPIGateway.Session.IsServer) { return; } var msgSnd = new MsgBlockSettings(); msgSnd.EntityId = block.Welder.EntityId; msgSnd.Settings = block.Settings.GetTransmit(); var res = false; if (MyAPIGateway.Session.IsServer) { if (steamId == 0) { if (Mod.Log.ShouldLog(Logging.Level.Info)) { Mod.Log.Write(Logging.Level.Info, "BuildAndRepairSystemMod: SyncBlockSettingsSend {0} to Others", Logging.BlockName(block.Welder, Logging.BlockNameOptions.None)); } res = MyAPIGateway.Multiplayer.SendMessageToOthers(MSGID_BLOCK_SETTINGS_FROM_SERVER, MyAPIGateway.Utilities.SerializeToBinary(msgSnd), true); } else { if (Mod.Log.ShouldLog(Logging.Level.Info)) { Mod.Log.Write(Logging.Level.Info, "BuildAndRepairSystemMod: SyncBlockSettingsSend {0} to {1}", Logging.BlockName(block.Welder, Logging.BlockNameOptions.None), steamId); } res = MyAPIGateway.Multiplayer.SendMessageTo(MSGID_BLOCK_SETTINGS_FROM_SERVER, MyAPIGateway.Utilities.SerializeToBinary(msgSnd), steamId, true); } } else { if (Mod.Log.ShouldLog(Logging.Level.Info)) { Mod.Log.Write(Logging.Level.Info, "BuildAndRepairSystemMod: SyncBlockSettingsSend {0} to Server", Logging.BlockName(block.Welder, Logging.BlockNameOptions.None)); } res = MyAPIGateway.Multiplayer.SendMessageToServer(MSGID_BLOCK_SETTINGS_FROM_CLIENT, MyAPIGateway.Utilities.SerializeToBinary(msgSnd), true); } if (!res && Mod.Log.ShouldLog(Logging.Level.Error)) { Mod.Log.Write(Logging.Level.Error, "BuildAndRepairSystemMod: SyncBlockSettingsSend failed", Logging.BlockName(block.Welder, Logging.BlockNameOptions.None)); } }
/// <summary> /// /// </summary> public static void SyncBlockStateSend(ulong steamId, NanobotBuildAndRepairSystemBlock system) { if (!MyAPIGateway.Session.IsServer) { return; } if (!MyAPIGateway.Multiplayer.MultiplayerActive) { return; } var msgSnd = new MsgBlockState(); msgSnd.EntityId = system.Entity.EntityId; msgSnd.State = system.State.GetTransmit(); var res = false; if (steamId == 0) { if (Mod.Log.ShouldLog(Logging.Level.Communication)) { Mod.Log.Write(Logging.Level.Communication, "BuildAndRepairSystemMod: SyncBlockStateSend to others EntityId={0}/{1}, State={2}", system.Entity.EntityId, Logging.BlockName(system.Entity, Logging.BlockNameOptions.None), msgSnd.State.ToString()); } res = MyAPIGateway.Multiplayer.SendMessageToOthers(MSGID_BLOCK_STATE_FROM_SERVER, MyAPIGateway.Utilities.SerializeToBinary(msgSnd), true); } else { if (Mod.Log.ShouldLog(Logging.Level.Communication)) { Mod.Log.Write(Logging.Level.Communication, "BuildAndRepairSystemMod: SyncBlockStateSend to SteamId={0} EntityId={1}/{2}, State={3}", steamId, system.Entity.EntityId, Logging.BlockName(system.Entity, Logging.BlockNameOptions.None), msgSnd.State.ToString()); } res = MyAPIGateway.Multiplayer.SendMessageTo(MSGID_BLOCK_STATE_FROM_SERVER, MyAPIGateway.Utilities.SerializeToBinary(msgSnd), steamId, true); } system.State.GetTransmit(); if (!res && Mod.Log.ShouldLog(Logging.Level.Error)) { Mod.Log.Write(Logging.Level.Error, "BuildAndRepairSystemMod: SyncBlockStateSend Failed"); } }
/// <summary> /// /// </summary> public static void SyncBlockStateSend(ulong steamId, NanobotBuildAndRepairSystemBlock system) { if (!MyAPIGateway.Utilities.IsDedicated && MyAPIGateway.Session.IsServer) { return; } var msgSnd = new MsgBlockState(); msgSnd.EntityId = system.Welder.EntityId; msgSnd.State = system.State.GetTransmit(); var res = false; if (steamId == 0) { if (Mod.Log.ShouldLog(Logging.Level.Info)) { Mod.Log.Write(Logging.Level.Info, "BuildAndRepairSystemMod: SyncBlockStateSend {0} to Others {1}/{2}", Logging.BlockName(system.Welder, Logging.BlockNameOptions.None), msgSnd.State.MissingComponentsSync.Count, msgSnd.State.PossibleWeldTargetsSync.Count); } res = MyAPIGateway.Multiplayer.SendMessageToOthers(MSGID_BLOCK_STATE_FROM_SERVER, MyAPIGateway.Utilities.SerializeToBinary(msgSnd), true); } else { if (Mod.Log.ShouldLog(Logging.Level.Info)) { Mod.Log.Write(Logging.Level.Info, "BuildAndRepairSystemMod: SyncBlockStateSend {0} to {1} {2}/{3}", Logging.BlockName(system.Welder, Logging.BlockNameOptions.None), steamId, msgSnd.State.MissingComponentsSync.Count, msgSnd.State.PossibleWeldTargetsSync.Count); } res = MyAPIGateway.Multiplayer.SendMessageTo(MSGID_BLOCK_STATE_FROM_SERVER, MyAPIGateway.Utilities.SerializeToBinary(msgSnd), steamId, true); } if (!res && Mod.Log.ShouldLog(Logging.Level.Error)) { Mod.Log.Write(Logging.Level.Error, "BuildAndRepairSystemMod: SyncBlockStateSend Failed"); } }
public void CheckLimits(NanobotBuildAndRepairSystemBlock system) { var maxValue = system != null ? system.WelderMaximumRange : NanobotBuildAndRepairSystemMod.Settings.Range; if (AreaWidthLeft > maxValue) { AreaWidthLeft = maxValue; } if (AreaWidthRight > maxValue) { AreaWidthRight = maxValue; } if (AreaHeightTop > maxValue) { AreaHeightTop = maxValue; } if (AreaHeightBottom > maxValue) { AreaHeightBottom = maxValue; } if (AreaDepthFront > maxValue) { AreaDepthFront = maxValue; } if (AreaDepthRear > maxValue) { AreaDepthRear = maxValue; } if (NanobotBuildAndRepairSystemMod.Settings.Welder.AllowBuildFixed) { AllowBuild = NanobotBuildAndRepairSystemMod.Settings.Welder.AllowBuildDefault; } if (NanobotBuildAndRepairSystemMod.Settings.Welder.UseIgnoreColorFixed) { UseIgnoreColor = NanobotBuildAndRepairSystemMod.Settings.Welder.UseIgnoreColorDefault; if (NanobotBuildAndRepairSystemMod.Settings.Welder.IgnoreColorDefault != null && NanobotBuildAndRepairSystemMod.Settings.Welder.IgnoreColorDefault.Length >= 3) { IgnoreColor = new Vector3D(NanobotBuildAndRepairSystemMod.Settings.Welder.IgnoreColorDefault[0], NanobotBuildAndRepairSystemMod.Settings.Welder.IgnoreColorDefault[1], NanobotBuildAndRepairSystemMod.Settings.Welder.IgnoreColorDefault[2]); } } if (NanobotBuildAndRepairSystemMod.Settings.Welder.UseGrindColorFixed) { UseGrindColor = NanobotBuildAndRepairSystemMod.Settings.Welder.UseGrindColorDefault; if (NanobotBuildAndRepairSystemMod.Settings.Welder.GrindColorDefault != null && NanobotBuildAndRepairSystemMod.Settings.Welder.GrindColorDefault.Length >= 3) { GrindColor = new Vector3D(NanobotBuildAndRepairSystemMod.Settings.Welder.GrindColorDefault[0], NanobotBuildAndRepairSystemMod.Settings.Welder.GrindColorDefault[1], NanobotBuildAndRepairSystemMod.Settings.Welder.GrindColorDefault[2]); } } if (NanobotBuildAndRepairSystemMod.Settings.Welder.ShowAreaFixed) { ShowArea = false; } if (NanobotBuildAndRepairSystemMod.Settings.Welder.AreaSizeFixed) { AreaWidthLeft = maxValue; AreaWidthRight = maxValue; AreaHeightTop = maxValue; AreaHeightBottom = maxValue; AreaDepthFront = maxValue; AreaDepthRear = maxValue; } if (NanobotBuildAndRepairSystemMod.Settings.Welder.SoundVolumeFixed) { SoundVolume = NanobotBuildAndRepairSystemMod.Settings.Welder.SoundVolumeDefault; } if (NanobotBuildAndRepairSystemMod.Settings.Welder.ScriptControllFixed) { ScriptControlled = false; } if ((NanobotBuildAndRepairSystemMod.Settings.Welder.AllowedSearchModes & SearchMode) == 0) { if ((NanobotBuildAndRepairSystemMod.Settings.Welder.AllowedSearchModes & SearchModes.Grids) != 0) { SearchMode = SearchModes.Grids; } else if ((NanobotBuildAndRepairSystemMod.Settings.Welder.AllowedSearchModes & SearchModes.BoundingBox) != 0) { SearchMode = SearchModes.BoundingBox; } } if ((NanobotBuildAndRepairSystemMod.Settings.Welder.AllowedWorkModes & WorkMode) == 0) { if ((NanobotBuildAndRepairSystemMod.Settings.Welder.AllowedWorkModes & WorkModes.WeldBeforeGrind) != 0) { WorkMode = WorkModes.WeldBeforeGrind; } else if ((NanobotBuildAndRepairSystemMod.Settings.Welder.AllowedWorkModes & WorkModes.GrindBeforeWeld) != 0) { WorkMode = WorkModes.GrindBeforeWeld; } else if ((NanobotBuildAndRepairSystemMod.Settings.Welder.AllowedWorkModes & WorkModes.GrindIfWeldGetStuck) != 0) { WorkMode = WorkModes.GrindIfWeldGetStuck; } } }