public static List <InteractiveChildObjectIdentifier> ExtractInteractiveChildren(GameObject constructedObject) { List <InteractiveChildObjectIdentifier> interactiveChildren = new List <InteractiveChildObjectIdentifier>(); string constructedObjectsName = constructedObject.GetFullName(); foreach (Type type in interactiveChildTypes) { Component[] components = constructedObject.GetComponentsInChildren(type, true); foreach (Component component in components) { NitroxId id = NitroxIdentifier.GetId(component.gameObject); string componentName = component.gameObject.GetFullName(); string relativePathName = componentName.Replace(constructedObjectsName, ""); // It can happen, that the game object is the constructed object itself. This code prevents to add itself to the child objects if (relativePathName.Length != 0) { relativePathName = relativePathName.TrimStart('/'); interactiveChildren.Add(new InteractiveChildObjectIdentifier(id, relativePathName)); } } } return(interactiveChildren); }
public override void Process(ModuleRemoved packet) { GameObject owner = NitroxIdentifier.RequireObjectFrom(packet.OwnerId); GameObject item = NitroxIdentifier.RequireObjectFrom(packet.ItemId); Pickupable pickupable = item.RequireComponent <Pickupable>(); Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner); if (opEquipment.IsPresent()) { Equipment equipment = opEquipment.Get(); Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment"); InventoryItem inventoryItem = itemsBySlot[packet.Slot]; itemsBySlot[packet.Slot] = null; equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), false }); Equipment.SendEquipmentEvent(pickupable, UNEQUIP_EVENT_TYPE_ID, owner, packet.Slot); equipment.ReflectionCall("NotifyUnequip", false, false, new object[] { packet.Slot, inventoryItem }); } else { Log.Error("Could not find equipment type for " + owner.name); } UnityEngine.Object.Destroy(item); }
public static void Prefix(BaseDeconstructable __instance) { NitroxId id = NitroxIdentifier.GetId(__instance.gameObject); Log.Info("Deconstructing " + id); TransientLocalObjectManager.Add(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID, id); }
public void BroadcastDestroyedVehicle(Vehicle vehicle) { using (packetSender.Suppress<VehicleOnPilotModeChanged>()) { NitroxId id = NitroxIdentifier.GetId(vehicle.gameObject); LocalPlayer localPlayer = NitroxServiceLocator.LocateService<LocalPlayer>(); VehicleDestroyed vehicleDestroyed = new VehicleDestroyed(id, localPlayer.PlayerName, vehicle.GetPilotingMode()); packetSender.Send(vehicleDestroyed); // If there is a pilotId then there is a remote player. We must // detach the remote player before destroying the game object. if (!string.IsNullOrEmpty(vehicle.pilotId)) { ushort pilot = ushort.Parse(vehicle.pilotId); Optional<RemotePlayer> remotePilot = playerManager.Find(pilot); if (remotePilot.IsPresent()) { RemotePlayer remotePlayer = remotePilot.Get(); remotePlayer.SetVehicle(null); remotePlayer.SetSubRoot(null); remotePlayer.SetPilotingChair(null); remotePlayer.AnimationController.UpdatePlayerAnimations = true; } } } }
public void BroadcastOnPilotModeChanged(Vehicle vehicle, bool isPiloting) { ushort playerId = multiplayerSession.Reservation.PlayerId; VehicleOnPilotModeChanged packet = new VehicleOnPilotModeChanged(NitroxIdentifier.GetId(vehicle.gameObject), playerId, isPiloting); packetSender.Send(packet); }
public void ToggleEngineState(NitroxId id, bool isStarting, bool isOn, bool silent = false) { GameObject cyclops = NitroxIdentifier.RequireObjectFrom(id); CyclopsEngineChangeState engineState = cyclops.RequireComponentInChildren <CyclopsEngineChangeState>(); CyclopsMotorMode motorMode = cyclops.RequireComponentInChildren <CyclopsMotorMode>(); if (isOn == engineState.motorMode.engineOn) { if ((isStarting != (bool)engineState.ReflectionGet("startEngine")) != isOn) { if (Player.main.currentSub != engineState.subRoot || silent) { engineState.ReflectionSet("startEngine", !isOn); engineState.ReflectionSet("invalidButton", true); engineState.Invoke("ResetInvalidButton", 2.5f); engineState.subRoot.BroadcastMessage("InvokeChangeEngineState", !isOn, SendMessageOptions.RequireReceiver); } else { engineState.ReflectionSet("invalidButton", false); using (packetSender.Suppress <CyclopsToggleInternalLighting>()) { engineState.OnClick(); } } } } }
public void ChangeSonarMode(NitroxId id, bool isOn) { GameObject cyclops = NitroxIdentifier.RequireObjectFrom(id); CyclopsSonarButton sonar = cyclops.GetComponentInChildren <CyclopsSonarButton>(); if (sonar != null) { using (packetSender.Suppress <CyclopsChangeSonarMode>()) { // At this moment the code is "non functional" as for some reason changing the sprite will never happen // Also setting sonar as active will never work MethodInfo sonarSetActiveInfo = sonar.GetType().GetMethod("set_sonarActive", BindingFlags.NonPublic | BindingFlags.Instance); if (sonarSetActiveInfo != null) { sonarSetActiveInfo.Invoke(sonar, new object[] { isOn }); } if (isOn) { sonar.image.sprite = sonar.activeSprite; } else { sonar.image.sprite = sonar.inactiveSprite; } } } }
public void BroadcastEquip(Pickupable pickupable, GameObject owner, string slot) { NitroxId ownerId = NitroxIdentifier.GetId(owner); NitroxId itemId = NitroxIdentifier.GetId(pickupable.gameObject); TechType techType = pickupable.GetTechType(); if (techType == TechType.VehicleStorageModule) { List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractInteractiveChildren(owner); VehicleChildUpdate vehicleChildInteractiveData = new VehicleChildUpdate(ownerId, childIdentifiers); packetSender.Send(vehicleChildInteractiveData); } Transform parent = pickupable.gameObject.transform.parent; pickupable.gameObject.transform.SetParent(null); byte[] bytes = SerializationHelper.GetBytes(pickupable.gameObject); EquippedItemData equippedItem = new EquippedItemData(ownerId, itemId, bytes, slot, techType.Model()); Player player = owner.GetComponent <Player>(); if (player != null) { PlayerEquipmentAdded equipmentAdded = new PlayerEquipmentAdded(techType.Model(), equippedItem); packetSender.Send(equipmentAdded); pickupable.gameObject.transform.SetParent(parent); return; } ModuleAdded moduleAdded = new ModuleAdded(equippedItem); packetSender.Send(moduleAdded); pickupable.gameObject.transform.SetParent(parent); }
public void BroadcastUnequip(Pickupable pickupable, GameObject owner, string slot) { NitroxId itemId = NitroxIdentifier.GetId(pickupable.gameObject); Player player = owner.GetComponent <Player>(); if (player != null) { TechType techType = pickupable.GetTechType(); PlayerEquipmentRemoved equipmentAdded = new PlayerEquipmentRemoved(techType.Model(), itemId); packetSender.Send(equipmentAdded); return; } NitroxId ownerId = NitroxIdentifier.GetId(owner); if (pickupable.GetTechType() == TechType.VehicleStorageModule) { List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractInteractiveChildren(owner); VehicleChildUpdate vehicleChildInteractiveData = new VehicleChildUpdate(ownerId, childIdentifiers); packetSender.Send(vehicleChildInteractiveData); } ModuleRemoved moduleRemoved = new ModuleRemoved(ownerId, slot, itemId); packetSender.Send(moduleRemoved); }
public void BroadcastItemRemoval(Pickupable pickupable, Transform ownerTransform) { NitroxId ownerId = null; bool isCyclopsLocker = Regex.IsMatch(ownerTransform.gameObject.name, @"Locker0([0-9])StorageRoot$", RegexOptions.IgnoreCase); bool isEscapePodStorage = ownerTransform.parent.name.StartsWith("EscapePod"); if (isCyclopsLocker) { ownerId = GetCyclopsLockerId(ownerTransform); } else if (isEscapePodStorage) { ownerId = GetEscapePodStorageId(ownerTransform); } else { ownerId = NitroxIdentifier.GetId(ownerTransform.transform.parent.gameObject); } NitroxId itemId = NitroxIdentifier.GetId(pickupable.gameObject); ItemContainerRemove remove = new ItemContainerRemove(ownerId, itemId); packetSender.Send(remove); }
public void AddItem(GameObject item, NitroxId containerId) { Optional <GameObject> owner = NitroxIdentifier.GetObjectFrom(containerId); if (owner.IsEmpty()) { Log.Info("Unable to find inventory container with id: " + containerId); return; } Optional <ItemsContainer> opContainer = InventoryContainerHelper.GetBasedOnOwnersType(owner.Get()); if (opContainer.IsPresent()) { ItemsContainer container = opContainer.Get(); Pickupable pickupable = item.RequireComponent <Pickupable>(); using (packetSender.Suppress <ItemContainerAdd>()) { container.UnsafeAdd(new InventoryItem(pickupable)); } } else { Log.Error("Could not find container field on object " + owner.Get().name); } }
public void BroadcastItemAdd(Pickupable pickupable, Transform ownerTransform) { NitroxId ownerId = null; bool isCyclopsLocker = Regex.IsMatch(ownerTransform.gameObject.name, @"Locker0([0-9])StorageRoot$", RegexOptions.IgnoreCase); bool isEscapePodStorage = ownerTransform.parent.name.StartsWith("EscapePod"); if (isCyclopsLocker) { ownerId = GetCyclopsLockerId(ownerTransform); } else if (isEscapePodStorage) { ownerId = GetEscapePodStorageId(ownerTransform); } else { ownerId = NitroxIdentifier.GetId(ownerTransform.transform.parent.gameObject); } NitroxId itemId = NitroxIdentifier.GetId(pickupable.gameObject); byte[] bytes = SerializationHelper.GetBytes(pickupable.gameObject); ItemData itemData = new ItemData(ownerId, itemId, bytes); ItemContainerAdd add = new ItemContainerAdd(itemData); packetSender.Send(add); }
public override void Process(EntityTransformUpdates packet) { foreach (EntityTransformUpdate entity in packet.Updates) { Optional <GameObject> opGameObject = NitroxIdentifier.GetObjectFrom(entity.Id); if (opGameObject.IsPresent()) { GameObject gameObject = opGameObject.Get(); float distance = Vector3.Distance(gameObject.transform.position, entity.Position); SwimBehaviour swimBehaviour = gameObject.GetComponent <SwimBehaviour>(); if (distance > 5 || swimBehaviour == null) { gameObject.transform.position = entity.Position; gameObject.transform.rotation = entity.Rotation; } else { swimBehaviour.SwimTo(entity.Position, 3f); } } } }
public override void Process(ExosuitArmActionPacket packet) { Optional <GameObject> opGameObject = NitroxIdentifier.GetObjectFrom(packet.ArmId); if (opGameObject.IsEmpty()) { Log.Error("Could not find exosuit arm"); return; } GameObject gameObject = opGameObject.Get(); switch (packet.TechType) { case TechType.ExosuitClawArmModule: exosuitModuleEvent.UseClaw(gameObject.GetComponent <ExosuitClawArm>(), packet.ArmAction); break; case TechType.ExosuitDrillArmModule: exosuitModuleEvent.UseDrill(gameObject.GetComponent <ExosuitDrillArm>(), packet.ArmAction); break; case TechType.ExosuitGrapplingArmModule: exosuitModuleEvent.UseGrappling(gameObject.GetComponent <ExosuitGrapplingArm>(), packet.ArmAction, packet.OpVector); break; case TechType.ExosuitTorpedoArmModule: exosuitModuleEvent.UseTorpedo(gameObject.GetComponent <ExosuitTorpedoArm>(), packet.ArmAction, packet.OpVector, packet.OpRotation); break; default: Log.Error("Got an arm tech that is not handled: " + packet.TechType + " with action: " + packet.ArmAction + " for id " + packet.ArmId); break; } }
public static bool Prefix(DockedVehicleHandTarget __instance, GUIHand hand) { vehicleDockingBay = __instance.dockingBay; Vehicle vehicle = vehicleDockingBay.GetDockedVehicle(); if (skipPrefix || vehicle == null) { return(true); } dockedVehicle = __instance; guiHand = hand; SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>(); NitroxId id = NitroxIdentifier.GetId(vehicle.gameObject); if (simulationOwnership.HasExclusiveLock(id)) { Log.Debug($"Already have an exclusive lock on this vehicle: {id}"); return(true); } simulationOwnership.RequestSimulationLock(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse); return(false); }
public void RemoveItem(NitroxId ownerId, bool silent = false) { GameObject owner = NitroxIdentifier.RequireObjectFrom(ownerId); Optional <EnergyMixin> opMixin = Optional <EnergyMixin> .OfNullable(owner.GetComponent <EnergyMixin>()); if (opMixin.IsPresent()) { EnergyMixin mixin = opMixin.Get(); StorageSlot slot = (StorageSlot)mixin.ReflectionGet("batterySlot"); // Suppress sound when silent is active // Will be used to suppress swap sound at the initialisation of the game bool allowedToPlaySounds = true; if (silent) { allowedToPlaySounds = (bool)mixin.ReflectionGet("allowedToPlaySounds"); mixin.ReflectionSet("allowedToPlaySounds", !silent); } using (packetSender.Suppress <StorageSlotItemRemove>()) { slot.RemoveItem(); } if (silent) { mixin.ReflectionSet("allowedToPlaySounds", allowedToPlaySounds); } } else { Log.Error("Removing storage slot item: Could not find storage slot field on object " + owner.name); } }
public static void Postfix(CyclopsSonarButton __instance) { NitroxId id = NitroxIdentifier.GetId(__instance.subRoot.gameObject); bool activeSonar = Traverse.Create(__instance).Field("sonarActive").GetValue <bool>(); NitroxServiceLocator.LocateService <Cyclops>().BroadcastChangeSonarState(id, activeSonar); }
public static bool Prefix(PilotingChair __instance, GUIHand hand) { if (skipPrefix) { return(true); } pilotingChair = __instance; guiHand = hand; SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>(); SubRoot subRoot = __instance.GetComponentInParent <SubRoot>(); Validate.NotNull(subRoot, "PilotingChair cannot find it's corresponding SubRoot!"); NitroxId id = NitroxIdentifier.GetId(subRoot.gameObject); if (simulationOwnership.HasExclusiveLock(id)) { Log.Debug($"Already have an exclusive lock on the piloting chair: {id}"); return(true); } simulationOwnership.RequestSimulationLock(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse); return(false); }
public void ChangeSilentRunning(NitroxId id, bool isOn) { GameObject cyclops = NitroxIdentifier.RequireObjectFrom(id); CyclopsSilentRunningAbilityButton ability = cyclops.RequireComponentInChildren <CyclopsSilentRunningAbilityButton>(); using (packetSender.Suppress <CyclopsChangeSilentRunning>()) { if ((bool)ability.ReflectionGet("active") != isOn) { Log.Debug("Set silent running to " + isOn + " for " + id); ability.ReflectionSet("active", isOn); if (isOn) { ability.image.sprite = ability.activeSprite; ability.subRoot.BroadcastMessage("RigForSilentRunning"); ability.InvokeRepeating("SilentRunningIteration", 0f, ability.silentRunningIteration); } else { ability.image.sprite = ability.inactiveSprite; ability.subRoot.BroadcastMessage("SecureFromSilentRunning"); ability.CancelInvoke("SilentRunningIteration"); } } } }
public override void Process(CyclopsDestroyed packet) { Optional <GameObject> cyclops = NitroxIdentifier.GetObjectFrom(packet.Id); // Despite me telling it to kill itself when I call LiveMixin.TakeDamage with massive damage, it doesn't seem to trigger like it should. // To get around this problem, I manually set the health to 0, then call for Kill(). Since Kill() does not trigger the necessary events, I do // it all manually below. At least this way I can make the screen shake hard enough to cause motion sickness, or disable it if I wanted to. if (cyclops.IsPresent()) { Log.Debug("[CyclopsDestroyedProcessor Id: " + packet.Id + "]"); SubRoot subRoot = cyclops.Get().RequireComponent <SubRoot>(); cyclops.Get().RequireComponent <LiveMixin>().ReflectionSet("health", 0f, true, false); cyclops.Get().RequireComponent <LiveMixin>().Kill(); // Copied from SubRoot.OnTakeDamage(DamageInfo info) subRoot.voiceNotificationManager.ClearQueue(); subRoot.voiceNotificationManager.PlayVoiceNotification(subRoot.abandonShipNotification, false, true); subRoot.Invoke("PowerDownCyclops", 13f); subRoot.Invoke("DestroyCyclopsSubRoot", 18f); float num = Vector3.Distance(subRoot.transform.position, Player.main.transform.position); if (num < 20f) { MainCameraControl.main.ShakeCamera(1.5f, 20f, MainCameraControl.ShakeMode.Linear, 1f); } if (subRoot.damageManager != null) { subRoot.damageManager.SendMessage("OnTakeDamage", null, SendMessageOptions.DontRequireReceiver); } } }
/// <summary> /// Send out a <see cref="CyclopsDamage"/> packet /// </summary> private void BroadcastDamageState(SubRoot subRoot, Optional <DamageInfo> info) { NitroxId subId = NitroxIdentifier.GetId(subRoot.gameObject); LiveMixin subHealth = subRoot.gameObject.RequireComponent <LiveMixin>(); if (subHealth.health > 0) { CyclopsDamageInfoData damageInfo = null; if (info.IsPresent()) { DamageInfo damage = info.Get(); // Source of the damage. Used if the damage done to the Cyclops was not calculated on other clients. Currently it's just used to figure out what sounds and // visual effects should be used. CyclopsDamageInfoData serializedDamageInfo = new CyclopsDamageInfoData(subId, damage.dealer != null ? NitroxIdentifier.GetId(damage.dealer) : null, damage.originalDamage, damage.damage, damage.position, damage.type); } int[] damagePointIndexes = GetActiveDamagePoints(subRoot).ToArray(); CyclopsFireData[] firePoints = GetActiveRoomFires(subRoot.GetComponent <SubFire>()).ToArray(); CyclopsDamage packet = new CyclopsDamage(subId, subRoot.GetComponent <LiveMixin>().health, subRoot.damageManager.subLiveMixin.health, subRoot.GetComponent <SubFire>().liveMixin.health, damagePointIndexes, firePoints, damageInfo); packetSender.Send(packet); } else { // RIP CyclopsDestroyed packet = new CyclopsDestroyed(subId); packetSender.Send(packet); } }
public void PickedUp(GameObject gameObject, TechType techType) { NitroxId id = NitroxIdentifier.GetId(gameObject); Vector3 itemPosition = gameObject.transform.position; PickedUp(itemPosition, id, techType); }
public void BroadcastVehicleDocking(VehicleDockingBay dockingBay, Vehicle vehicle) { NitroxId dockId; if (dockingBay.GetSubRoot() is BaseRoot) { dockId = NitroxIdentifier.GetId(dockingBay.GetComponentInParent<BaseRoot>().gameObject); } else if (dockingBay.GetSubRoot() is SubRoot) { dockId = NitroxIdentifier.GetId(dockingBay.GetSubRoot().gameObject); } else { dockId = NitroxIdentifier.GetId(dockingBay.GetComponentInParent<ConstructableBase>().gameObject); } NitroxId vehicleId = NitroxIdentifier.GetId(vehicle.gameObject); ushort playerId = multiplayerSession.Reservation.PlayerId; VehicleDocking packet = new VehicleDocking(vehicleId, dockId, playerId); packetSender.Send(packet); PacketSuppressor<Movement> movementSuppressor = packetSender.Suppress<Movement>(); vehicle.StartCoroutine(AllowMovementPacketsAfterDockingAnimation(movementSuppressor)); }
public static void Postfix(CyclopsFireSuppressionSystemButton __instance) { SubRoot cyclops = __instance.subRoot; NitroxId id = NitroxIdentifier.GetId(cyclops.gameObject); NitroxServiceLocator.LocateService <Cyclops>().BroadcastActivateFireSuppression(id); }
// As the normal spawn is suppressed, spawn default batteries afterwards private void SpawnDefaultBatteries(GameObject constructedObject, List <InteractiveChildObjectIdentifier> childIdentifiers) { Optional <EnergyMixin> opEnergy = Optional <EnergyMixin> .OfNullable(constructedObject.GetComponent <EnergyMixin>()); if (opEnergy.IsPresent()) { EnergyMixin mixin = opEnergy.Get(); mixin.ReflectionSet("allowedToPlaySounds", false); mixin.SetBattery(mixin.defaultBattery, 1); mixin.ReflectionSet("allowedToPlaySounds", true); } foreach (InteractiveChildObjectIdentifier identifier in childIdentifiers) { Optional <GameObject> opChildGameObject = NitroxIdentifier.GetObjectFrom(identifier.Id); if (opChildGameObject.IsPresent()) { Optional <EnergyMixin> opEnergyMixin = Optional <EnergyMixin> .OfNullable(opChildGameObject.Get().GetComponent <EnergyMixin>()); if (opEnergyMixin.IsPresent()) { EnergyMixin mixin = opEnergyMixin.Get(); mixin.ReflectionSet("allowedToPlaySounds", false); mixin.SetBattery(mixin.defaultBattery, 1); mixin.ReflectionSet("allowedToPlaySounds", true); } } } }
public void PlaceFurniture(GameObject gameObject, TechType techType, Vector3 itemPosition, Quaternion quaternion) { if (!Builder.isPlacing) //prevent possible echoing { return; } NitroxId id = NitroxIdentifier.GetId(gameObject); Optional <NitroxId> subId = Optional <NitroxId> .Empty(); SubRoot sub = Player.main.currentSub; if (sub != null) { subId = Optional <NitroxId> .Of(NitroxIdentifier.GetId(sub.gameObject)); } Transform camera = Camera.main.transform; Optional <RotationMetadata> rotationMetadata = Optional <RotationMetadata> .Empty(); BasePiece basePiece = new BasePiece(id, itemPosition, quaternion, camera.position, camera.rotation, techType.Model(), subId, true, rotationMetadata); PlaceBasePiece placedBasePiece = new PlaceBasePiece(basePiece); packetSender.Send(placedBasePiece); }
public Optional <GameObject> Spawn(Entity entity, Optional <GameObject> parent) { TechType techType = entity.TechType.Enum(); GameObject prefab; IPrefabRequest prefabRequest = PrefabDatabase.GetPrefabAsync(entity.ClassId); if (!prefabRequest.TryGetPrefab(out prefab)) // I realize its more code but Sorry couldnt stand all the warnings { prefab = CraftData.GetPrefabForTechType(techType, false); if (prefab == null) { return(Optional <GameObject> .Of(Utils.CreateGenericLoot(techType))); } } GameObject gameObject = Utils.SpawnFromPrefab(prefab, null); gameObject.transform.position = entity.Position; gameObject.transform.localScale = entity.Scale; if (parent.IsPresent()) { gameObject.transform.SetParent(parent.Get().transform, true); } gameObject.transform.localRotation = entity.Rotation; gameObject.SetActive(true); NitroxIdentifier.SetNewId(gameObject, entity.Id); LargeWorldEntity.Register(gameObject); CrafterLogic.NotifyCraftEnd(gameObject, techType); return(Optional <GameObject> .Of(gameObject)); }
public void ConstructionComplete(GameObject ghost) { NitroxId baseId = null; Optional <object> opConstructedBase = TransientLocalObjectManager.Get(TransientObjectType.BASE_GHOST_NEWLY_CONSTRUCTED_BASE_GAMEOBJECT); NitroxId id = NitroxIdentifier.GetId(ghost); if (opConstructedBase.IsPresent()) { GameObject constructedBase = (GameObject)opConstructedBase.Get(); baseId = NitroxIdentifier.GetId(constructedBase); } // For base pieces, we must switch the id from the ghost to the newly constructed piece. // Furniture just uses the same game object as the ghost for the final product. if (ghost.GetComponent <ConstructableBase>() != null) { Optional <object> opBasePiece = TransientLocalObjectManager.Get(TransientObjectType.LATEST_CONSTRUCTED_BASE_PIECE); GameObject finishedPiece = (GameObject)opBasePiece.Get(); UnityEngine.Object.Destroy(ghost); NitroxIdentifier.SetNewId(finishedPiece, id); if (baseId == null) { baseId = NitroxIdentifier.GetId(finishedPiece.GetComponentInParent <Base>().gameObject); } } ConstructionCompleted constructionCompleted = new ConstructionCompleted(id, baseId); packetSender.Send(constructionCompleted); }
public override void Process(CyclopsActivateHorn hornPacket) { GameObject cyclops = NitroxIdentifier.RequireObjectFrom(hornPacket.Id); CyclopsHornControl horn = cyclops.RequireComponentInChildren <CyclopsHornControl>(); Utils.PlayEnvSound(horn.hornSound, horn.hornSound.gameObject.transform.position, 20f); }
public override void Process(DeconstructionBegin packet) { GameObject deconstructing = NitroxIdentifier.RequireObjectFrom(packet.Id); Constructable constructable = deconstructing.RequireComponent <Constructable>(); constructable.SetState(false, false); }