public override void OnBeforeBuild() { if (Context.HasComponent <NetCodeBuildSettings>()) { NetCodeBuildSettings netCodeBuildSettings = Context.GetComponentOrDefault <NetCodeBuildSettings>(); oldIP = netCodeBuildSettings.config.IP; oldPort = netCodeBuildSettings.config.Port; oldTargetWorld = netCodeBuildSettings.config.StartupWorld; netCodeBuildSettings.config.IP = netCodeBuildSettings.IP; netCodeBuildSettings.config.Port = netCodeBuildSettings.Port; if (netCodeBuildSettings.Client && netCodeBuildSettings.Server) { netCodeBuildSettings.config.StartupWorld = TargetWorld.ClientAndServer; } else if (netCodeBuildSettings.Client) { netCodeBuildSettings.config.StartupWorld = TargetWorld.Client; } else if (netCodeBuildSettings.Server) { netCodeBuildSettings.config.StartupWorld = TargetWorld.Server; } } }
protected void RemoveComponent(GameObject prefab, TargetWorld target) { var ghostAuthoring = prefab.GetComponent <GhostAuthoringComponent>(); var toRemove = new HashSet <string>(); if (target == TargetWorld.Server) { foreach (GhostAuthoringComponent.GhostComponentInfo ghostComponent in ghostAuthoring.Components) { if (!ghostComponent.server) { toRemove.Add(ghostComponent.name); } } } else if (target == TargetWorld.Client) { if (ghostAuthoring.Type == GhostAuthoringComponent.ClientInstanceType.Interpolated) { foreach (GhostAuthoringComponent.GhostComponentInfo ghostComponent in ghostAuthoring.Components ) { if (!ghostComponent.interpolatedClient) { toRemove.Add(ghostComponent.name); } } } else { foreach (GhostAuthoringComponent.GhostComponentInfo ghostComponent in ghostAuthoring.Components ) { if (!ghostComponent.predictedClient) { toRemove.Add(ghostComponent.name); } } } } var monoComponents = ghostAuthoring.GetComponents(typeof(Component)); foreach (var comp in monoComponents) { // 移除DOTS转换组件 if (toRemove.Contains(comp.GetType().FullName) || (comp is IConvertGameObjectToEntity && !(comp is IConvertNotRemove))) { Destroy(comp); } } }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { TargetWorld targetWorld = GhostAuthoringConversion.GetConversionTarget(dstManager.World); if (targetWorld != TargetWorld.Client) { return; } if (GetComponent <GhostAuthoringComponent>().Type != GhostAuthoringComponent.ClientInstanceType.Interpolated) { dstManager.AddBuffer <HistoryStateData>(entity); } }
/// <summary> /// 分类系统 /// </summary> /// <param name="type"></param> /// <param name="target"></param> /// <param name="explicitWorld"></param> protected internal static void AddToSystems(Type type, TargetWorld target, bool explicitWorld = true) { if (target.HasFlag(TargetWorld.Default)) { if (explicitWorld) { SystemStates.ExplicitDefaultWorldSystems.Add(type); } else { SystemStates.DefaultWorldSystems.Add(type); } } if (target.HasFlag(TargetWorld.Client)) { SystemStates.ClientSystems.Add(type); } if (target.HasFlag(TargetWorld.Server)) { SystemStates.ServerSystems.Add(type); } }
public UpdateInWorldAttribute(TargetWorld w) { World = w; }
public UpdateInWorld(TargetWorld w) { m_world = w; }
public void CalculateDistanceToTarget() { if (travel == false) { int distanceToMoon = 52638263, distanceToMars = 159134924, distanceToEarth = 369420840; double timeToMoon = 71.52, timeToMars = 213.91, timeToEarth = 439.62; if (harvestedWorlds[1] == "1") { if (harvestedWorlds[2] == "1") { timeToEarth += timeToMars + timeToMoon; distanceToEarth += distanceToMars + distanceToMoon; } else if (harvestedWorlds[3] == "1") { timeToMars += timeToEarth + timeToMoon; distanceToMars += distanceToEarth + distanceToMoon; } else { timeToEarth += timeToMoon; timeToEarth += timeToMoon; distanceToEarth += distanceToMoon; distanceToMars += distanceToMoon; } } else if (harvestedWorlds[2] == "1") { if (harvestedWorlds[3] == "1") { timeToMoon += timeToMars + timeToEarth; distanceToMoon += distanceToMars + distanceToEarth; } else { timeToEarth += timeToMars; timeToMoon += timeToMars; distanceToEarth += distanceToMars; distanceToMoon += distanceToMars; } } else if (harvestedWorlds[3] == "1") { timeToMoon += timeToEarth; timeToMars += timeToEarth; distanceToMoon += distanceToEarth; distanceToMars += distanceToEarth; } Print(""); PrintWithRepetition($"Calculating distance to {TargetWorld} "); Print("Distance: " + (TargetWorld.ToString() == "Moon" ? $"≈ {distanceToMoon} km" : (TargetWorld.ToString() == "Mars" ? $"≈ {distanceToMars} km" : $"≈ {distanceToEarth} km"))); Print(""); Print($"Setting a course for {TargetWorld}."); Print("ETA: " + (TargetWorld.ToString() == "Moon" ? $"≈ {timeToMoon} hours" : (TargetWorld.ToString() == "Mars" ? $"≈ {timeToMars} hours" : $"≈ {timeToEarth} hours"))); Print(""); Print($"{ChosenClass} status: Inactive until arrival on {TargetWorld} "); } else { Print(""); Print($"{ChosenClass} is already at the location of the targeted world"); } }
public void EvaluateSituation() { if (status == true) { Print($"[{ChosenClass}] Status: Active"); PrintWithRepetition($"[{ChosenClass}] Assessing current situation"); Print($"[{ChosenClass}] World: {TargetWorld}"); Print($"[{ChosenClass}] Population: {TargetWorld.Population}"); Print($"[{ChosenClass}] Health: {ChosenClass.Health}"); if (TargetWorld.LifeForms) { int notExistingTargets = 0; Print($"[{ChosenClass}] Hostile life forms: "); foreach (Target target in TargetWorld.Targets) { Print($"[{ChosenClass}] {target}: {target.Amount}"); if (target.Amount == 0) { notExistingTargets++; } } if (notExistingTargets == TargetWorld.Targets.Count) { TargetWorld.LifeForms = false; EvaluateSituation(); } } else { int choice = 1; bool correct = false; if (TargetWorld.ToString() == "Moon") { harvestedWorlds[1] = "1"; } else if (TargetWorld.ToString() == "Mars") { harvestedWorlds[2] = "1"; } else { harvestedWorlds[3] = "1"; } Print($"[{ChosenClass}] All hostiles have been harvested"); Print($"[{ChosenClass}] {TargetWorld}: Harvested"); if (harvestedWorlds[1] == "0" || harvestedWorlds[2] == "0" || harvestedWorlds[3] == "0") { Print($"[{ChosenClass}] Proceed to harvest the next world: Yes <Use the arrow keys to switch between 'Yes' and 'No'>"); while (correct == false) { switch (Console.ReadKey().Key) { case ConsoleKey.LeftArrow: Console.SetCursorPosition(ChosenClass.ToString().Length + 38, rows); choice = (choice + 1) % 2; if (choice == 0) { Print("No "); } else { Print("Yes"); } rows--; Console.SetCursorPosition(0, rows + 1); break; case ConsoleKey.RightArrow: Console.SetCursorPosition(ChosenClass.ToString().Length + 38, rows); choice = (choice + 1) % 2; if (choice == 0) { Print("No "); } else { Print("Yes"); } rows--; Console.SetCursorPosition(0, rows + 1); break; case ConsoleKey.Enter: correct = true; break; default: Console.SetCursorPosition(0, rows + 1); Console.Write(" "); Console.SetCursorPosition(0, rows + 1); break; } } if (choice == 1) { currentTarget = 0; travel = false; status = false; boot = false; ShutDownRobot(); rows++; GetTargetWorld(); Boot(); CalculateDistanceToTarget(); Travel(); Activate(); EvaluateSituation(); } else { consoleShutDown = true; ShutDownRobot(); Print("Mission: Success"); PrintWithRepetition("Console shutting down"); Print("FINISHED"); } } else { consoleShutDown = true; Print($"[{ChosenClass}] All worlds have been harvested"); ShutDownRobot(); Print("Mission: Success"); PrintWithRepetition("Console shutting down"); Print("FINISHED"); } } } else { Print("Robot is deactivated."); } }