public static bool Prefix(Rocket __instance) { GameObject gameObject = __instance.gameObject; NitroxId id = NitroxEntity.GetId(gameObject); Optional <NeptuneRocketModel> model = NitroxServiceLocator.LocateService <Vehicles>().TryGetVehicle <NeptuneRocketModel>(id); if (!model.HasValue) { Log.Error($"{nameof(Rocket_Start_Patch)}: Could not find NeptuneRocketModel by Nitrox id {id}.\nGO containing wrong id: {__instance.GetHierarchyPath()}"); return(false); } __instance.currentRocketStage = model.Value.CurrentStage; RocketConstructor rocketConstructor = gameObject.GetComponentInChildren <RocketConstructor>(true); if (rocketConstructor) { NitroxEntity.SetNewId(rocketConstructor.gameObject, model.Value.ConstructorId); } else { Log.Error($"{nameof(Rocket_Start_Patch)}: Could not find attached RocketConstructor to rocket with id {id}"); } if (__instance.currentRocketStage > 0) { __instance.elevatorState = model.Value.ElevatorUp ? Rocket.RocketElevatorStates.AtTop : Rocket.RocketElevatorStates.AtBottom; __instance.elevatorPosition = model.Value.ElevatorUp ? 1f : 0f; __instance.ReflectionCall("SetElevatorPosition", false, false); } return(true); }
public static void Callback(Rocket rocketInstanceAttachedToConstructor, RocketConstructor rocketConstructor, TechType currentStageTech, GameObject gameObjectToBuild) { NitroxId rocketId = NitroxEntity.GetId(rocketInstanceAttachedToConstructor.gameObject); NitroxId constructorId = NitroxEntity.GetId(rocketConstructor.gameObject); NitroxServiceLocator.LocateService <Rockets>().BroadcastRocketStateUpdate(rocketId, constructorId, currentStageTech, gameObjectToBuild); }
public override void Process(RocketStageUpdate packet) { GameObject gameObjectRocket = NitroxEntity.RequireObjectFrom(packet.Id); Rocket rocket = gameObjectRocket.RequireComponent <Rocket>(); GameObject build = rocket.StartRocketConstruction(); ItemGoalTracker.OnConstruct(packet.CurrentStageTech); RocketConstructor rocketConstructor = gameObjectRocket.RequireComponentInChildren <RocketConstructor>(true); rocketConstructor.SendBuildBots(build); }
internal void ConstructNextNeptuneRocketPiece() { if (_rocketConstructor == null) { // Global search call required as RocketConstructor host is unknown. // TODO: Optimise with GetComponent call on known host object. _rocketConstructor = FindObjectOfType <RocketConstructor>(); // In case the user ran the script // before the Neptune Launch Platform // was built. if (_rocketConstructor == null) { return; } } // Successive calls to StartRocketConstruction // will actually advance the current rocket // stage and build the next piece. _rocketConstructor.StartRocketConstruction(); }
public override void Process(RocketStageUpdate packet) { GameObject gameObjectConstructor = NitroxEntity.RequireObjectFrom(packet.ConstructorId); GameObject gameObjectRocket = NitroxEntity.RequireObjectFrom(packet.Id); Rocket rocket = gameObjectRocket.RequireComponent <Rocket>(); rocket.StartRocketConstruction(); ItemGoalTracker.OnConstruct(packet.CurrentStageTech); RocketConstructor rocketConstructor = gameObjectConstructor.GetComponentInChildren <RocketConstructor>(true); if (rocketConstructor) { GameObject gameObjectTobuild = SerializationHelper.GetGameObject(packet.SerializedGameObject); rocketConstructor.ReflectionCall("SendBuildBots", false, false, gameObjectTobuild); } else { Log.Error($"{nameof(RocketStageUpdateProcessor)}: Can't find attached rocketconstructor with id {packet.ConstructorId} for rocket with id {packet.Id}"); } }