예제 #1
0
        public override bool SharedOnDamage(
            WeaponFinalCache weaponCache,
            IStaticWorldObject targetObject,
            double damagePreMultiplier,
            out double obstacleBlockDamageCoef,
            out double damageApplied)
        {
            if (weaponCache.ProtoExplosive is not null)
            {
                // allow to explode only a resource deposit which could be claimed
                if (WorldMapResourceMarksSystem.SharedCalculateTimeRemainsToClaimCooldownSeconds(targetObject)
                    <= 0)
                {
                    // accept explosive damage
                    return(base.SharedOnDamage(weaponCache,
                                               targetObject,
                                               damagePreMultiplier,
                                               out obstacleBlockDamageCoef,
                                               out damageApplied));
                }

                using var tempScopedBy = Api.Shared.GetTempList <ICharacter>();
                Server.World.GetScopedByPlayers(targetObject, tempScopedBy);
                this.CallClient(tempScopedBy.AsList(),
                                _ => _.ClientRemote_NoDamageToDepositUnderClaimDelay(weaponCache.ProtoExplosive));
            }

            // only damage from explosives is accepted
            obstacleBlockDamageCoef = 0;
            damageApplied           = 0; // no damage
            return(false);               // no hit
        }
예제 #2
0
        private int CalculateTimeToClaim()
        {
            if (this.worldObjectDeposit is null)
            {
                return(0);
            }

            var mark = WorldMapResourceMarksSystem.SharedEnumerateMarks()
                       .FirstOrDefault(m => m.Id == this.worldObjectDeposit.Id);

            return((int)WorldMapResourceMarksSystem.SharedCalculateTimeToClaimLimitRemovalSeconds(mark.ServerSpawnTime));
        }
예제 #3
0
        protected override void ServerInitialize(ServerInitializeData data)
        {
            base.ServerInitialize(data);

            var privateState = data.PrivateState;

            if (data.IsFirstTimeInit)
            {
                privateState.ServerSpawnTime = Server.Game.FrameTime;
            }

            WorldMapResourceMarksSystem.ServerAddMark(data.GameObject,
                                                      privateState.ServerSpawnTime);
        }
예제 #4
0
        protected override void ServerInitialize(ServerInitializeData data)
        {
            base.ServerInitialize(data);

            var privateState = data.PrivateState;

            if (data.IsFirstTimeInit)
            {
                privateState.ServerSpawnTime = this.LifetimeTotalDurationSeconds > 0
                                                   ? Server.Game.FrameTime
                                                   : 0;
            }

            WorldMapResourceMarksSystem.ServerAddMark(data.GameObject,
                                                      privateState.ServerSpawnTime);
        }
예제 #5
0
        private int CalculateTimeToClaim()
        {
            if (this.worldObjectDeposit == null)
            {
                return(0);
            }

            var position = WorldMapResourceMarksSystem.SharedGetObjectCenterPosition(this.worldObjectDeposit);
            var mark     = WorldMapResourceMarksSystem.SharedEnumerateMarks()
                           .FirstOrDefault(m => m.Position == position &&
                                           m.ProtoWorldObject == this.protoDeposit);

            if (mark.Position == default)
            {
                return(0);
            }

            return((int)WorldMapResourceMarksSystem.SharedCalculateTimeToClaimLimitRemovalSeconds(
                       mark.ServerSpawnTime));
        }
예제 #6
0
        protected virtual int ServerDecayIntervalSeconds => 60; // every minute

        public override void ServerOnDestroy(IStaticWorldObject gameObject)
        {
            base.ServerOnDestroy(gameObject);
            WorldMapResourceMarksSystem.ServerRemoveMark(gameObject);
        }
예제 #7
0
 protected override void ServerInitialize(ServerInitializeData data)
 {
     base.ServerInitialize(data);
     WorldMapResourceMarksSystem.ServerAddMark(data.GameObject);
 }