コード例 #1
0
        public void ServerReduceHealth(double damage, IProtoGameObject damageSource)
        {
            if (damage <= 0)
            {
                return;
            }

            if (damageSource != null)
            {
                // it's important to register the damage source before the damage is applied
                // (to use it in case of the subsequent death)
                CharacterDamageTrackingSystem.ServerRegisterDamage(damage,
                                                                   (ICharacter)this.GameObject,
                                                                   new ServerDamageSourceEntry(damageSource));
            }

            var newHealth = this.HealthCurrent - damage;

            if (newHealth <= 0 &&
                ((ICharacter)this.GameObject).IsNpc &&
                damageSource is IProtoStatusEffect)
            {
                // Don't allow killing mob by a status effect.
                // This is a workaround to kill quests which cannot be finished
                // as the final damage is done by a status effect.
                // TODO: Should be removed when we enable the damage tracking for mobs damage.
                newHealth = float.Epsilon;
            }

            this.ServerSetHealthCurrent((float)newHealth);
        }
コード例 #2
0
        public ServerDamageSourceEntry(IGameObjectWithProto byGameObject)
        {
            this.ProtoEntity = byGameObject.ProtoGameObject;

            if (byGameObject is ICharacter character &&
                !character.IsNpc)
            {
                this.Name = byGameObject.Name;
            }
コード例 #3
0
        public ServerDamageSourceEntry(IGameObjectWithProto byGameObject)
        {
            this.ProtoEntity = byGameObject.ProtoGameObject;

            if (byGameObject is ICharacter byPlayerCharacter &&
                !byPlayerCharacter.IsNpc)
            {
                this.Name    = byPlayerCharacter.Name;
                this.ClanTag = PlayerCharacter.GetPublicState(byPlayerCharacter).ClanTag;
            }
コード例 #4
0
        private void ClientRemote_NoDamageToDepositUnderClaimDelay(IProtoGameObject protoObjectExplosive)
        {
            var icon = protoObjectExplosive switch
            {
                IProtoObjectExplosive objectExplosive => objectExplosive.Icon,
                IProtoItem item => item.Icon,
                _ => null
            };

            NotificationSystem.ClientShowNotification(
                string.Format(NotificationNoDamageToDepositUnderCooldown_TitleFormat, this.Name),
                NotificationNoDamageToDepositUnderCooldown_Description,
                color: NotificationColor.Bad,
                icon);
        }
    }
コード例 #5
0
        private ObjectSpawnPreset FindPreset(IProtoGameObject protoGameObject)
        {
            if (!(protoGameObject is IProtoSpawnableObject protoSpawnableObject))
            {
                // not spawnable objects cannot have presets
                return(null);
            }

            foreach (var preset in this.SpawnList)
            {
                if (preset.Contains(protoSpawnableObject))
                {
                    return(preset);
                }
            }

            return(null);
        }
コード例 #6
0
        /// <summary>
        /// Server spawn callback (generic).
        /// </summary>
        /// <param name="trigger">Trigger leading to this spawn.</param>
        /// <param name="zone">Server zone instance.</param>
        /// <param name="protoGameObject">Prototype of object to spawn.</param>
        /// <param name="tilePosition">Position to try spawn at.</param>
        protected IGameObjectWithProto ServerSpawn(
            IProtoTrigger trigger,
            IServerZone zone,
            IProtoGameObject protoGameObject,
            Vector2Ushort tilePosition)
        {
            switch (protoGameObject)
            {
            case IProtoStaticWorldObject protoStaticWorldObject:
                return(this.ServerSpawnStaticObject(trigger, zone, protoStaticWorldObject, tilePosition));

            case IProtoCharacterMob protoMob:
                return(this.ServerSpawnMob(trigger, zone, protoMob, tilePosition));

            case IProtoItem protoItem:
                return(this.ServerSpawnItem(trigger, zone, protoItem, tilePosition));

            default:
                throw new Exception("Server don't know how to spawn this type of object - " + protoGameObject);
            }
        }
コード例 #7
0
 public ServerDamageSourceEntry(IProtoGameObject byProtoEntity)
 {
     this.ProtoEntity = byProtoEntity;
     this.Name        = null;
     this.ClanTag     = null;
 }
コード例 #8
0
 private bool IsTradingStation(IProtoGameObject worldObject)
 {
     return(worldObject is ObjectTradingStationSmallFridge || worldObject is ObjectTradingStationLargeFridge);
 }