private void ConstructionAmountChanged(ConstructionAmountChangedEvent amountChanged) { Log.Debug($"Processing ConstructionAmountChanged {amountChanged.Id} {amountChanged.Amount}"); GameObject constructing = NitroxEntity.RequireObjectFrom(amountChanged.Id); BaseDeconstructable baseDeconstructable = constructing.GetComponent <BaseDeconstructable>(); // Bases don't send a deconstruct being packet. Instead, we just make sure // that if we are changing the amount that we set it into deconstruction mode // if it still has a BaseDeconstructable object on it. if (baseDeconstructable != null) { baseDeconstructable.Deconstruct(); // After we have begun the deconstructing for a base piece, we need to transfer the id Optional <object> opGhost = TransientLocalObjectManager.Get(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GHOST); if (opGhost.HasValue) { GameObject ghost = (GameObject)opGhost.Value; Destroy(constructing); NitroxEntity.SetNewId(ghost, amountChanged.Id); } else { Log.Error($"Could not find newly created ghost to set deconstructed id {amountChanged.Id}"); } } else { Constructable constructable = constructing.GetComponentInChildren <Constructable>(); constructable.constructedAmount = amountChanged.Amount; constructable.Construct(); } }
private void ConstructionAmountChanged(ConstructionAmountChangedEvent amountChanged) { Log.Debug("Processing ConstructionAmountChanged " + amountChanged.Guid + " " + amountChanged.Amount); GameObject constructing = GuidHelper.RequireObjectFrom(amountChanged.Guid); Constructable constructable = constructing.GetComponent <Constructable>(); constructable.constructedAmount = amountChanged.Amount; using (packetSender.Suppress <ConstructionAmountChanged>()) { constructable.Construct(); } }
private void ConstructionAmountChanged(ConstructionAmountChangedEvent amountChanged) { Log.Info("Processing ConstructionAmountChanged " + amountChanged.Guid + " " + amountChanged.Amount); GameObject constructing = GuidHelper.RequireObjectFrom(amountChanged.Guid); BaseDeconstructable baseDeconstructable = constructing.GetComponent <BaseDeconstructable>(); // Bases don't send a deconstruct being packet. Instead, we just make sure // that if we are changing the amount that we set it into deconstruction mode // if it still has a BaseDeconstructable object on it. if (baseDeconstructable != null) { baseDeconstructable.Deconstruct(); // After we have begun the deconstructing for a base piece, we need to transfer the guid Optional <object> opGhost = TransientLocalObjectManager.Get(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE); if (opGhost.IsPresent()) { GameObject ghost = (GameObject)opGhost.Get(); UnityEngine.Object.Destroy(constructing); GuidHelper.SetNewGuid(ghost, amountChanged.Guid); } else { Log.Info("Could not find newly created ghost to set deconstructed guid "); } } else { Constructable constructable = constructing.GetComponentInChildren <Constructable>(); constructable.constructedAmount = amountChanged.Amount; using (packetSender.Suppress <ConstructionAmountChanged>()) { constructable.Construct(); } } }