Ejemplo n.º 1
0
        public SkillResult(EachSkillResultServerMessage message, EntityTracker entityRegistry, PlayerTracker playerTracker, SkillDatabase skillDatabase)
        {
            Time       = message.Time;
            Amount     = message.Amount;
            IsCritical = message.IsCritical;
            IsHeal     = message.IsHeal;
            SkillId    = message.SkillId;

            Source = entityRegistry.GetOrPlaceholder(message.Source);
            Target = entityRegistry.GetOrPlaceholder(message.Target);
            var sourceUser = Source.RootOwner as UserEntity; // Attribute damage dealt by owned entities to the owner
            var targetUser = Target as UserEntity;           // But don't attribute damage received by owned entities to the owner

            if (sourceUser != null)
            {
                Skill        = skillDatabase.GetOrNull(sourceUser, message.SkillId);
                SourcePlayer = playerTracker.Get(sourceUser.ServerId, sourceUser.PlayerId);
            }

            if (targetUser != null)
            {
                TargetPlayer = playerTracker.Get(targetUser.ServerId, targetUser.PlayerId);
            }
        }