Beispiel #1
0
        public void Use(IEntity user, IEntity skill)
        {
            var eventData = new ActivateSkillEventData {
                SkillName = skill.Get <Prototype>().Name
            };

            var canSelectSkill = systemContainer.EventSystem.Try(EventType.SelectSkill, user, eventData);

            if (canSelectSkill)
            {
                var scriptName = skill.Get <Skill>().ScriptName;

                var script = systemContainer.PrototypeSystem.Get(scriptName);

                var scriptText = script.Get <Script>().Text;

                var onCompleteAction = new Action(() => OnComplete(user, skill));

                // Construct a new one rather than using the one in container so that it doesn't use up the onComplete slot.
                var scriptExecutor = new ScriptExecutor(systemContainer);

                scriptExecutor.Execute(user, scriptText, skill, onCompleteAction);
            }
        }
Beispiel #2
0
        public void CreateSystems(string rngSeed)
        {
            ScriptExecutor = new ScriptExecutor(this);
            EventSystem    = new EventSystem.EventSystem();

            MessageSystem  = new MessageSystem();
            ActivitySystem = new ActivitySystem();
            PlayerSystem   = new PlayerSystem(ActivitySystem);
            MapSystem      = new MapSystem();


            RendererSystem = new RendererSystem(PlayerSystem, ActivitySystem, _renderer);

            EntityEngine = new EntityEngine(_prototypeEntityDataProvider, _additionalComponentTypes);

            StatSystem = new StatSystem(EntityEngine);

            PositionSystem = new PositionSystem(MapSystem, EntityEngine, new AStarPathfindingAlgorithm());
            EntityEngine.Register(PositionSystem);

            Random          = new RNG(rngSeed);
            AnimationRandom = new RNG(rngSeed);

            TimeSystem = new TimeSystem(this);
            EntityEngine.Register(TimeSystem);

            FighterSystem = new FighterSystem(EntityEngine, MessageSystem, EventSystem, TimeSystem, StatSystem);
            EntityEngine.Register(FighterSystem);

            PrototypeSystem = new PrototypeSystem(EntityEngine, PositionSystem, this);
            EntityEngine.Register(PrototypeSystem);

            ItemSystem = new ItemSystem(EntityEngine, PrototypeSystem, ScriptExecutor, MessageSystem, EventSystem);
            EntityEngine.Register(ItemSystem);

            SkillSystem = new SkillSystem(this);
            EntityEngine.Register(SkillSystem);

            AnimationSystem = new AnimationSystem(new EncapsulatedStopwatch(), AnimationRandom);
            EntityEngine.Register(AnimationSystem);

            AnimatedMovementSystem = new AnimatedMovementSystem(EntityEngine, new EncapsulatedStopwatch());
            EntityEngine.Register(AnimatedMovementSystem);

            ParticleSystem = new ParticleSystem(AnimationSystem, EntityEngine);
            EntityEngine.Register(ParticleSystem);

            SoundSystem = new SoundSystem();
            EntityEngine.Register(SoundSystem);

            InteractableSystem = new InteractionSystem(PositionSystem);
            EntityEngine.Register(InteractableSystem);

            Seed = rngSeed;

            EquipmentSystem = new EquipmentSystem(this);

            TargetingSystem = new TargetingSystem(this);

            FactionSystem = new FactionSystem();

            ControlSystem = new ControlSystem(this, _keyBindingsDataProvider);

            SaveSystem = new SaveSystem(this, new WorldGenerator(_worldEntityDataProvider, _playerEntityDataProvider, _vaultDataProvider));


            EntityEngine.Initialise(this);
            ControlSystem.Initialise();

            Verify();
        }