Ejemplo n.º 1
0
        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 static void Prefix(BaseDeconstructable __instance)
        {
            string guid = GuidHelper.GetGuid(__instance.gameObject);

            Log.Info("Deconstructing " + guid);
            TransientLocalObjectManager.Add(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID, guid);
        }
        public static void Prefix(BaseDeconstructable __instance)
        {
            NitroxId id = NitroxEntity.GetId(__instance.gameObject);

            Log.Info("Deconstructing " + id);
            NitroxServiceLocator.LocateService <Building>().DeconstructionBegin(id);

            TransientLocalObjectManager.Add(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID, id);
        }
        /**
         * On base pieces we need to have special logic during deconstruction to transfer the id from the main
         * object to the ghost.  This method will see if we have a stored LATEST_DECONSTRUCTED_BASE_PIECE_GUID
         * (set from deconstructor patch).  If we do, then we'll copy the id to the new ghost.  This is in
         * amount changed as we don't currently have a good hook for 'startDeconstruction'; this method will
         * run its logic on the first amount changed instead - effectively the same thing.
         */
        public static void CheckToCopyIdToGhost(Constructable __instance)
        {
            Optional <object> opId = TransientLocalObjectManager.Get(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID);

            if (opId.IsPresent())
            {
                TransientLocalObjectManager.Add(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID, null);

                NitroxId id = (NitroxId)opId.Get();
                Log.Info("Setting ghost id " + id);
                NitroxEntity.SetNewId(__instance.gameObject, id);
            }
        }
        /**
         * On base pieces we need to have special logic during deconstruction to transfer the guid from the main
         * object to the ghost.  This method will see if we have a stored LATEST_DECONSTRUCTED_BASE_PIECE_GUID
         * (set from deconstructor patch).  If we do, then we'll copy the guid to the new ghost.  This is in
         * amount changed as we don't currently have a good hook for 'startDeconstruction'; this method will
         * run its logic on the first amount changed instead - effectively the same thing.
         */
        public static void CheckToCopyGuidToGhost(Constructable __instance)
        {
            Optional <object> opGuid = TransientLocalObjectManager.Get(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID);

            if (opGuid.IsPresent())
            {
                TransientLocalObjectManager.Add(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID, null);

                string guid = (string)opGuid.Get();
                Log.Info("Setting ghost guid " + guid);
                GuidHelper.SetNewGuid(__instance.gameObject, guid);
            }
        }
Ejemplo n.º 6
0
        public override void Process(DeconstructionBegin packet)
        {
            Log.Info("Received deconstruction packet for basePieceId: " + packet.Id);

            GameObject          deconstructing      = NitroxEntity.RequireObjectFrom(packet.Id);
            BaseDeconstructable baseDeconstructable = deconstructing.RequireComponent <BaseDeconstructable>();

            TransientLocalObjectManager.Add(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID, packet.Id);

            using (packetSender.Suppress <DeconstructionBegin>())
            {
                baseDeconstructable.Deconstruct();
            }
        }
Ejemplo n.º 7
0
        public static void Postfix(Constructable __instance)
        {
            /**
             * On base pieces we need to have special logic during deconstruction to transfer the id from the main
             * object to the ghost.  This method will see if we have a stored LATEST_DECONSTRUCTED_BASE_PIECE_GUID
             * (set from deconstructor patch or incoming deconstruction packet).  If we do, then we'll copy the id
             * to the new ghost.
             */
            Optional <object> opId = TransientLocalObjectManager.Get(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID);

            if (opId.IsPresent())
            {
                TransientLocalObjectManager.Add(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID, null);

                NitroxId id = (NitroxId)opId.Get();
                Log.Info("Setting ghost id via Constructable_SetState_Patch " + id);
                NitroxEntity.SetNewId(__instance.gameObject, id);
            }
        }
Ejemplo n.º 8
0
        public static void Prefix(BaseGhost __instance)
        {
            // Null out fields that will be used for storing state
            TransientLocalObjectManager.Remove(TransientObjectType.LATEST_BASE_WITH_NEW_CONSTRUCTION);
            TransientLocalObjectManager.Remove(TransientObjectType.LATEST_BASE_CELL_WITH_NEW_CONSTRUCTION);

            // In this case, our piece is part of an existing, larger base.  We'll record the base and offset.
            // We don't directly record the piece as it will be re-built when the base rebuilds geometry (this
            // happens each time a piece is built, subnautica destroys all others and replaces them).
            if (__instance.TargetBase != null)
            {
                Log.Debug("Placed BaseGhost is a new piece of an existing base");
                TransientLocalObjectManager.Add(TransientObjectType.LATEST_BASE_WITH_NEW_CONSTRUCTION, __instance.TargetBase);
                TransientLocalObjectManager.Add(TransientObjectType.LATEST_BASE_CELL_WITH_NEW_CONSTRUCTION, __instance.TargetOffset);
            }
            else
            {
                Log.Debug("Placed BaseGhost is the first piece of a new base.");
            }
        }
Ejemplo n.º 9
0
        public override void Process(DeconstructionBegin packet)
        {
            Log.Info("Received deconstruction packet for id: " + packet.Id);

            GameObject deconstructing = NitroxEntity.RequireObjectFrom(packet.Id);

            Constructable       constructable       = deconstructing.GetComponent <Constructable>();
            BaseDeconstructable baseDeconstructable = deconstructing.GetComponent <BaseDeconstructable>();

            using (packetSender.Suppress <DeconstructionBegin>())
            {
                if (baseDeconstructable != null)
                {
                    TransientLocalObjectManager.Add(TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE_GUID, packet.Id);
                    baseDeconstructable.Deconstruct();
                }
                else if (constructable != null)
                {
                    constructable.SetState(false, false);
                }
            }
        }
 public static void Callback(GameObject gameObject)
 {
     TransientLocalObjectManager.Add(TransientLocalObjectManager.TransientObjectType.LATEST_DECONSTRUCTED_BASE_PIECE, gameObject);
 }
 public static void Postfix(BaseDeconstructable __instance)
 {
     TransientLocalObjectManager.Add(TransientObjectType.LATEST_CONSTRUCTED_BASE_PIECE, __instance.gameObject);
 }