Ejemplo n.º 1
0
 public FlightControl(SerializationInfo info, StreamingContext context)
 {
     ItemPool.LoadAsset <FlightControlConfig>(info.GetValue(nameof(Config), ""), a => Config = a);
     CurrentMode      = info.GetValue(nameof(CurrentMode), CurrentMode);
     EnginesActivated = info.GetValue(nameof(EnginesActivated), EnginesActivated);
     ClearValues();
 }
Ejemplo n.º 2
0
        public DirectionalSpriteAnimationComponent(SerializationInfo info, StreamingContext context)
        {
            _unscaled     = info.GetValue(nameof(_unscaled), _unscaled);
            Billboard     = info.GetValue(nameof(Billboard), Billboard);
            Facing        = info.GetValue(nameof(Facing), Facing);
            Backwards     = info.GetValue(nameof(Backwards), Backwards);
            CurrentClipID = info.GetValue(nameof(CurrentClipID), CurrentClipID);
            _animDict     = info.GetValue(nameof(_animDict), _animDict);

            var currentSet = new Dictionary <string, List <DirectionalAnimation> >();

            for (int i = 0; i < _animDict.Count; i++)
            {
                var line = _animDict[i];
                if (!currentSet.TryGetValue(line.Key, out var setList))
                {
                    setList = new List <DirectionalAnimation>();
                    currentSet.Add(line.Key, setList);
                }
                var animation = ItemPool.LoadAsset <DirectionalAnimation>(UnityDirs.CharacterAnimations, line.Value);
                if (animation != null)
                {
                    setList.Add(animation);
                }
            }
            Setup(currentSet);
            if (!string.IsNullOrEmpty(CurrentClipID))
            {
                PlayAnimation(CurrentClipID, false, null);
            }
        }
Ejemplo n.º 3
0
 public FlightEngine(SerializationInfo info, StreamingContext context)
 {
     ItemPool.LoadAsset <FlightEngineConfig>(info.GetValue(nameof(Config), ""), a => Config = a);
     AvailableBoostForces       = info.GetValue(nameof(AvailableBoostForces), AvailableBoostForces);
     AvailableRotationForces    = info.GetValue(nameof(AvailableRotationForces), AvailableRotationForces);
     AvailableTranslationForces = info.GetValue(nameof(AvailableTranslationForces), AvailableTranslationForces);
     MaxTranslationForces       = info.GetValue(nameof(MaxTranslationForces), MaxTranslationForces);
     RefreshEngine();
 }
Ejemplo n.º 4
0
 public AddModImpact(SerializationInfo info, StreamingContext context)
 {
     Length            = info.GetValue(nameof(Length), Length);
     TargetStat        = info.GetValue(nameof(TargetStat), TargetStat);
     NormalizedPercent = info.GetValue(nameof(NormalizedPercent), NormalizedPercent);
     ID            = info.GetValue(nameof(ID), ID);
     _iconLocation = info.GetValue(nameof(_iconLocation), _iconLocation);
     ItemPool.LoadAsset <Sprite>(_iconLocation, a => Icon = a);
 }
Ejemplo n.º 5
0
 public SpriteAnimationComponent(SerializationInfo info, StreamingContext context)
 {
     _component        = info.GetValue(nameof(_component), _component);
     Unscaled          = info.GetValue(nameof(Unscaled), Unscaled);
     Billboard         = info.GetValue(nameof(Billboard), Billboard);
     NextUpdateTime    = info.GetValue(nameof(NextUpdateTime), NextUpdateTime);
     CurrentFrameIndex = info.GetValue(nameof(CurrentFrameIndex), CurrentFrameIndex);
     LastAngleHeight   = info.GetValue(nameof(LastAngleHeight), LastAngleHeight);
     ItemPool.LoadAsset <SpriteAnimation>(info.GetValue(nameof(Animation), ""), a => Animation = a);
 }
Ejemplo n.º 6
0
 public Action(SerializationInfo info, StreamingContext context)
 {
     Sequence     = info.GetValue(nameof(Sequence), Sequence);
     Costs        = info.GetValue(nameof(Costs), Costs);
     Range        = info.GetValue(nameof(Range), Range);
     WeaponModel  = info.GetValue(nameof(WeaponModel), WeaponModel);
     Primary      = info.GetValue(nameof(Primary), Primary);
     EquippedSlot = info.GetValue(nameof(EquippedSlot), EquippedSlot);
     _ammo        = info.GetValue(nameof(_ammo), _ammo);
     Fx           = ItemPool.LoadAsset <ActionFx>(info.GetValue(nameof(Fx), ""));
 }
        public SpriteRenderingSystem()
        {
            TemplateFilter <SpriteRendererTemplate> .Setup();

            _rendererList = EntityController.GetTemplateList <SpriteRendererTemplate>();
            _rendererDel  = RunUpdate;

            TemplateFilter <SpriteRendererInstancedTemplate> .Setup();

            _rendererInstancedList = EntityController.GetTemplateList <SpriteRendererInstancedTemplate>();
            _rendererInstancedDel  = RunUpdate;

            _simpleRenderers   = EntityController.GetComponentArray <SpriteSimpleRendererComponent>();
            _simpleRendererDel = RunUpdate;

            ItemPool.LoadAsset <Material>(MaterialAddress, (m) => _material = m);
        }
Ejemplo n.º 8
0
        private ParticlePlayer GetPlayer()
        {
            ParticlePlayer player = null;

            if (_pool.Count > 0)
            {
                player = _pool.Pop();
                player.Renderer.enabled = true;
            }
            else
            {
                if (_prefab == null)
                {
                    _prefab = ItemPool.LoadAsset <GameObject>(UnityDirs.Particles, PrefabName);
                }
                var newPlayer = UnityEngine.Object.Instantiate(_prefab);
                player = new ParticlePlayer(newPlayer.GetComponent <SpriteRenderer>());
            }
            player.Tr.SetParent(null);
            return(player);
        }
Ejemplo n.º 9
0
 public ActionFxComponent(SerializationInfo info, StreamingContext context)
 {
     Fx = ItemPool.LoadAsset <ActionFx>(info.GetValue(nameof(Fx), ""));
 }
Ejemplo n.º 10
0
        public void AddComponent(Entity entity, DataEntry data)
        {
            var action = entity.Add(new ActionConfig());

            var type  = data.Get <DataReference>(DatabaseFields.ItemType);
            var skill = data.TryGetValue <string>(DatabaseFields.Skill, "");

            action.Primary     = type?.TargetID == "WeaponUsable";
            action.WeaponModel = data.TryGetValue("WeaponModel", "");
            if (!string.IsNullOrEmpty(action.WeaponModel))
            {
                entity.Add(new WeaponModelComponent(action.WeaponModel));
            }
            else
            {
                action.WeaponModel = data.TryGetValue("SpriteWeaponModel", "");
            }
            var stats = entity.Get <StatsContainer>();
            var power = new RangeStat(entity, Stats.Power, Stats.Power, data.TryGetValue(DatabaseFields.PowerMin, 0f), data.TryGetValue
                                          (DatabaseFields.PowerMax, 1f));

            stats.Add(power);
            bool generateCollision = false;
            var  targeting         = ParseUtilities.TryParseEnum(data.TryGetValue("TargetType", "Enemy"), TargetType.Enemy);

            if (targeting == TargetType.Self || targeting == TargetType.Friendly)
            {
                generateCollision = true;
            }
            bool limitEnemy  = true;
            var  config      = data.Get <DataList>("Config");
            var  abilityType = data.TryGetValue("Type", "Attack");
            var  damageType  = data.TryGetValue(DatabaseFields.DamageType,
                                                GameData.DamageTypes.GetID(0));

            if (type != null && type.TargetID == "Ability")
            {
                action.AnimationTrigger = data.TryGetValue("Animation", GraphTriggers.UseAbility);
                action.EquipVariable    = "";
                var secondaryType = data.TryGetValue("SecondaryType", "");
                switch (abilityType)
                {
                default:
                case "Attack":
                    entity.Add(
                        new DamageImpact(damageType, Stats.Health, 1));
                    break;

                case "Heal":
                    entity.Add(AddHealImpact(config, false));
                    generateCollision = true;
                    limitEnemy        = false;
                    break;

                case "AddModImpact":
                    entity.Add(AddModImpact(entity, config));
                    generateCollision = true;
                    limitEnemy        = false;
                    break;

                case "Teleport":
                case "Shield":
                case "Unlock":
                    break;
                }
                switch (secondaryType)
                {
                case "Heal":
                    entity.Add(AddHealImpact(config, true));
                    break;

                case "AddModImpact":
                    entity.Add(AddModImpact(entity, config));
                    break;

                case "ConvertVital":
                    entity.Add(new ConvertVitalImpact(config.FindFloat("Percent", 1f), config.FindString("SourceVital"), config.FindString("TargetVital")));
                    break;

                case "InstantKill":
                    entity.Add(new InstantKillImpact(config.FindFloat("Chance", 1f)));
                    break;

                case "Confuse":
                    entity.Add(
                        new ApplyTagImpact(EntityTags.IsConfused, data.TryGetValue("SecondaryPower", EffectChance), config
                                           .FindFloat("Length", EffectTime), damageType, "Confusion"));
                    break;

                case "Slow":
                    entity.Add(new ApplyTagImpact(EntityTags.IsSlowed, data.TryGetValue("SecondaryPower", EffectChance), config
                                                  .FindFloat("Length", EffectTime), damageType, "Slow"));
                    break;

                case "Stun":
                    entity.Add(new ApplyTagImpact(EntityTags.IsStunned, data.TryGetValue("SecondaryPower", EffectChance), config
                                                  .FindFloat("Length", EffectTime), damageType, "Stun"));
                    break;
                }
                switch (abilityType)
                {
                default:
                    action.Costs.Add(new CostVital(Stats.Energy, data.TryGetValue("Cost", 1f), skill));
                    break;

                case "Shield":
                case "Unlock":
                    break;
                }
            }
            else
            {
                action.AnimationTrigger = GraphTriggers.Attack;
                action.EquipVariable    = data.TryGetValue("EquipVariable", "");
                entity.Add(
                    new DamageImpact(data.TryGetValue(DatabaseFields.DamageType,
                                                      GameData.DamageTypes.GetID(0)), Stats.Health, 1));
                var           reload      = data.TryGetValue("ReloadType", "Repair");
                var           reloadSpeed = data.TryGetValue("ReloadSpeed", 1f);
                var           ammo        = AmmoFactory.GetTemplate(data.Get <DataReference>("Ammo"));
                AmmoComponent ammoComponent;
                switch (reload)
                {
                case "Repair":
                    ammoComponent = entity.Add(new AmmoComponent(ammo, skill, reloadSpeed, power, _brokenWeaponPercent));
                    var handlers = entity.GetOrAdd <RuleEventListenerComponent>();
                    handlers.Handlers.Add(World.Get <AmmoSystem>());
                    break;

                default:
                case "Reload":
                    ammoComponent = entity.Add(new AmmoComponent(ammo, skill, reloadSpeed, null));
                    action.Costs.Add(new CostAmmo(ammoComponent));
                    break;
                }
                ammoComponent.Amount.SetLimits(0, data.TryGetValue("AmmoAmount", 5));
                ammoComponent.Amount.SetMax();
            }
            switch (abilityType)
            {
            default:
                var radius = ParseUtilities.TryParseEnum(data.TryGetValue(DatabaseFields.Radius, "Single"), ImpactRadiusTypes.Single);
                if (radius != ImpactRadiusTypes.Single)
                {
                    entity.Add(new ImpactRadius(radius, true));
                }
                action.Range = GameData.ActionDistance.GetAssociatedValue(data.TryGetValue("Range", "Medium"));
                var spawn = data.Get <DataReference>(DatabaseFields.ActionSpawn);
                if (spawn != null)
                {
                    action.AddEvent(AnimationEvents.Default, new EventSpawnProjectile(spawn.TargetID));
                }
                else
                {
                    if (generateCollision)
                    {
                        action.AddEvent(AnimationEvents.Default, new EventGenerateCollisionEvent());
                    }
                    else
                    {
                        var collisionType = data.TryGetValue("CollisionType", "Point");
                        var raycastSize   = GameData.CollisionType.GetAssociatedValue(collisionType) * 0.01f;
                        switch (collisionType)
                        {
                        case "Melee":
                        case "MeleeBig":
                            action.AddEvent(AnimationEvents.CollisionOrImpact, new CameraShakeEvent(new Vector3
                                                                                                        (0, 0, 1), 4, false));
                            break;
                        }
                        //melee or hitscan need to make that clearer
                        action.AddEvent(AnimationEvents.Default, new EventCheckRaycastCollision(action.Range, raycastSize, limitEnemy));
                    }
                }
                break;

            case "Shield":
                entity.Add(
                    new BlockDamageAction(
                        config.FindString("Model", "Shield"), "Vitals.Energy",
                        data.TryGetValue("Cost", 1f), skill, PlayerControls.UseSecondary));
                break;
                //case "Teleport":
                //    sequence.Add(new PlayActionAnimation(ActionStateEvents.None, animation, true, false, true));
                //    sequence.Add(new WaitForAnimation(ActionStateEvents.Activate, animation, true, _defaultAnimationTimeout));
                //    sequence.Add(new TeleportSequence(ActionStateEvents.None, config.FindInt("Distance", 5)));
                //    break;
                //case "Unlock":
                //    sequence.Add(new PlayActionAnimation(ActionStateEvents.None, animation, true, false, true));
                //    sequence.Add(new WaitForAnimation(ActionStateEvents.Activate, animation, true, _defaultAnimationTimeout));
                //    sequence.Add(new Unlock(ActionStateEvents.None, power.UpperRange, data.TryGetValue("Cost", 1f)));
                //    break;
            }
            var afx = data.GetValue <string>(DatabaseFields.ActionFx);

            if (!string.IsNullOrEmpty(afx))
            {
                var actionFx = ItemPool.LoadAsset <ActionFx>(UnityDirs.ActionFx, afx);
                if (actionFx != null)
                {
                    if (actionFx.TryGetColor(out var actionColor))
                    {
                        entity.Add(new HitParticlesComponent(actionColor));
                    }
                    entity.Add(new ActionFxComponent(actionFx));
                }
            }
            var customScripting = data.Get <DataList>("ScriptedEvents");

            if (customScripting != null)
            {
                for (int i = 0; i < customScripting.Count; i++)
                {
                    var scriptingData = customScripting[i];
                    var eventType     = scriptingData.TryGetValue("Event", "");
                    //var eventType = ParseUtilities.TryParseEnum(scriptingData.TryGetValue("Event", ""), ActionState.None);
                    var scripting = scriptingData.TryGetValue("Script", "");
                    if (!string.IsNullOrEmpty(eventType) && !string.IsNullOrEmpty(scripting))
                    {
                        var customScript = ScriptingSystem.ParseMessage(scripting.SplitIntoWords());
                        if (customScript != null)
                        {
                            action.AddEvent(eventType, customScript);
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
 public IconComponent(string iconLocation)
 {
     Sprite       = ItemPool.LoadAsset <Sprite>(iconLocation);
     IconLocation = iconLocation;
 }
Ejemplo n.º 12
0
 public IconComponent(string dir, string icon)
 {
     Sprite = ItemPool.LoadAsset <Sprite>(IconLocation);
 }
Ejemplo n.º 13
0
 public IconComponent(SerializationInfo info, StreamingContext context)
 {
     IconLocation = info.GetValue(nameof(IconLocation), IconLocation);
     ItemPool.LoadAsset <Sprite>(IconLocation, a => Sprite = a);
 }
Ejemplo n.º 14
0
 public AudioClipSetData(SerializationInfo info, StreamingContext context)
 {
     Set = ItemPool.LoadAsset <AudioClipSet>(info.GetValue(nameof(Set), ""));
 }
Ejemplo n.º 15
0
 public IconComponent(string dir, string icon)
 {
     IconLocation = ItemPool.GetCombinedLocator(dir, icon);
     Sprite       = ItemPool.LoadAsset <Sprite>(IconLocation);
 }
Ejemplo n.º 16
0
 public HoverEngine(SerializationInfo info, StreamingContext context)
 {
     ItemPool.LoadAsset <HoverEngineConfig>(info.GetValue(nameof(Config), ""), a => Config = a);
     Drag = Config.DriveForce / Config.MaxForwardSpeed;
     RefreshPid();
 }
Ejemplo n.º 17
0
 public ActionFxComponent(SerializationInfo info, StreamingContext context)
 {
     ItemPool.LoadAsset <ActionFx>(info.GetValue(nameof(Value), ""), a => Value = a);
 }
Ejemplo n.º 18
0
        public static Entity CreateItem(ItemConfig data, int level)
        {
            var entity = Entity.New(data.ID);

            entity.Add(new TypeId(data.ID));
            if (!string.IsNullOrEmpty(data.Icon))
            {
                entity.Add(new IconComponent(ItemPool.LoadAsset <Sprite>(UnityDirs.ItemIcons, data.Icon)));
            }
            else
            {
                entity.Add(new IconComponent(SpriteDatabase.Item));
            }
            entity.Add(new EntityLevelComponent(level));
            if (data.TypeComponents != null)
            {
                World.Get <DataFactory>().AddComponentList(entity, data.Data, data.TypeComponents);
            }
            if (data.Components != null)
            {
                World.Get <DataFactory>().AddComponentList(entity, data.Data, data.Components);
            }
            ItemModifierFactory.AddModifiers(data.ModifierGroup, level, entity);
            StringBuilder sbName  = new StringBuilder();
            StringBuilder sbDescr = new StringBuilder();

            sbDescr.Append(data.Description);
            var prefix = entity.Get <ItemModifierPrefix>();
            var suffix = entity.Get <ItemModifierSuffix>();

            if (prefix != null)
            {
                var prefixLabel = prefix.Data.TryGetValue(DatabaseFields.Name, "");
                if (!string.IsNullOrEmpty(prefixLabel))
                {
                    sbName.Append(prefixLabel);
                    sbName.Append(" ");
                }
                var prefixDescr = prefix.Data.TryGetValue(DatabaseFields.Description, "");
                if (!string.IsNullOrEmpty(prefixDescr))
                {
                    sbDescr.NewLine();
                    sbDescr.Append(prefixDescr);
                }
            }

            sbName.Append(data.Name);
            if (suffix != null)
            {
                var suffixLabel = suffix.Data.TryGetValue(DatabaseFields.Name, "");
                if (!string.IsNullOrEmpty(suffixLabel))
                {
                    sbName.Append(" ");
                    sbName.Append(suffixLabel);
                }
                var suffixDescr = suffix.Data.TryGetValue(DatabaseFields.Description, "");
                if (!string.IsNullOrEmpty(suffixDescr))
                {
                    sbDescr.NewLine();
                    sbDescr.Append(suffixDescr);
                }
            }
            entity.Add(new LabelComponent(sbName.ToString()));
            entity.Add(new DescriptionComponent(sbDescr.ToString()));
            var dataDescr = entity.Add(new DataDescriptionComponent());

            entity.Post(new DataDescriptionAdded(dataDescr));
            return(entity);
        }
Ejemplo n.º 19
0
 public FakeFlightEngine(SerializationInfo info, StreamingContext context)
 {
     Config = ItemPool.LoadAsset <FakeFlightEngineConfig>(info.GetValue(nameof(Config), ""));
 }
Ejemplo n.º 20
0
 public CosmeticFlightBanking(SerializationInfo info, StreamingContext context)
 {
     _bankTransform = info.GetValue(nameof(_bankTransform), _bankTransform);
     ItemPool.LoadAsset <FlightControlConfig>(info.GetValue(nameof(Config), ""), a => Config = a);
 }