コード例 #1
0
        public override void ServerOnDestroy(IDynamicWorldObject gameObject)
        {
            base.ServerOnDestroy(gameObject);

            // try drop extra containers on the ground
            var privateState = GetPrivateState(gameObject);

            DropItemsToTheGround(privateState.EquipmentItemsContainer);
            //DropItemsToTheGround(privateState.FuelItemsContainer); // consider fuel items were destroyed during the explosion

            void DropItemsToTheGround(IItemsContainer itemsContainer)
            {
                if (itemsContainer?.OccupiedSlotsCount == 0)
                {
                    return;
                }

                var groundContainer = ObjectGroundItemsContainer.ServerTryDropOnGroundContainerContent(
                    gameObject.Tile,
                    itemsContainer);

                if (groundContainer != null)
                {
                    // set custom timeout for the dropped ground items container
                    ObjectGroundItemsContainer.ServerSetDestructionTimeout(
                        (IStaticWorldObject)groundContainer.Owner,
                        DestroyedCargoDroppedItemsDestructionTimeout.TotalSeconds);
                }
            }
        }
コード例 #2
0
        public override void ServerOnDestroy(IStaticWorldObject gameObject)
        {
            base.ServerOnDestroy(gameObject);

            LandClaimSystem.ServerOnObjectLandClaimDestroyed(gameObject);

            // try drop items from the safe storage
            var itemsContainer = GetPrivateState(gameObject).ItemsContainer;

            if (itemsContainer.OccupiedSlotsCount == 0)
            {
                // no items to drop
                return;
            }

            var groundContainer = ObjectGroundItemsContainer.ServerTryDropOnGroundContainerContent(
                gameObject.OccupiedTile,
                itemsContainer);

            if (groundContainer == null)
            {
                // no items dropped
                return;
            }

            // set custom timeout for the dropped ground items container
            ObjectGroundItemsContainer.ServerSetDestructionTimeout(
                (IStaticWorldObject)groundContainer.Owner,
                DestroyedLandClaimDroppedItemsDestructionTimeout.TotalSeconds);
        }
コード例 #3
0
        public static void ServerTryClaim(
            IWorldObject worldObject,
            ICharacter character,
            double durationSeconds,
            bool claimForPartyMembers = true)
        {
            if (!SharedIsEnabled)
            {
                return;
            }

            if (worldObject is null ||
                character is null ||
                character.IsNpc ||
                durationSeconds <= 0)
            {
                return;
            }

            var worldObjectPublicState = worldObject.AbstractPublicState as IWorldObjectPublicStateWithClaim;

            if (worldObjectPublicState is null)
            {
                Logger.Warning(
                    $"{worldObject} doesn't implement {nameof(IWorldObjectPublicStateWithClaim)} - cannot claim it");
                return;
            }

            var objectClaim = worldObjectPublicState.WorldObjectClaim;

            if (objectClaim is not null)
            {
                // already claimed
                WorldObjectClaim.ServerTryExtendClaim(objectClaim, character, durationSeconds);
                return;
            }

            objectClaim = Server.World.CreateLogicObject <WorldObjectClaim>();
            WorldObjectClaim.ServerSetupClaim(objectClaim,
                                              character,
                                              worldObject,
                                              durationSeconds,
                                              claimForPartyMembers);
            worldObjectPublicState.WorldObjectClaim = objectClaim;
            //Logger.Dev("World object claim added: " + worldObject);

            if (worldObject.ProtoGameObject is ObjectGroundItemsContainer)
            {
                // set custom timeout for the ground items container to ensure it cannot be removed from the world
                // before the claim expires
                ObjectGroundItemsContainer.ServerSetDestructionTimeout(
                    (IStaticWorldObject)worldObject,
                    durationSeconds);
            }
        }
コード例 #4
0
        public override void ServerOnDestroy(IStaticWorldObject gameObject)
        {
            base.ServerOnDestroy(gameObject);

            var itemsContainer = GetPrivateState(gameObject).ItemsContainer;

            if (itemsContainer.OccupiedSlotsCount == 0)
            {
                return;
            }

            var groundContainer = ObjectGroundItemsContainer.ServerTryDropOnGroundContainerContent(
                gameObject.OccupiedTile,
                itemsContainer);

            if (groundContainer != null)
            {
                // set custom timeout for the dropped ground items container
                ObjectGroundItemsContainer.ServerSetDestructionTimeout(
                    (IStaticWorldObject)groundContainer.Owner,
                    DestroyedCrateDroppedItemsDestructionTimeout.TotalSeconds);
            }
        }
コード例 #5
0
        public static void ServerOnDestroy(IStaticWorldObject tradingStation)
        {
            TradingStationsMapMarksSystem.ServerTryRemoveMark(tradingStation);

            var itemsContainer = GetPrivateState(tradingStation).StockItemsContainer;

            if (itemsContainer.OccupiedSlotsCount == 0)
            {
                return;
            }

            var groundContainer = ObjectGroundItemsContainer.ServerTryDropOnGroundContainerContent(
                tradingStation.OccupiedTile,
                itemsContainer);

            if (groundContainer != null)
            {
                // set custom timeout for the dropped ground items container
                ObjectGroundItemsContainer.ServerSetDestructionTimeout(
                    (IStaticWorldObject)groundContainer.Owner,
                    DestroyedTradingStationDroppedItemsDestructionTimeout.TotalSeconds);
            }
        }