Esempio n. 1
0
        public override void OnDetached(AbstractEntity entity)
        {
            Game.Instance.Simulation.CurrentUpdateQueue.AddUpdate(new RemoveRenderableUpdate((Renderable)Updatable));

            if (entity.HasVector3(CommonNames.Position))
            {
                entity.GetVector3Attribute(CommonNames.Position).ValueChanged -= PositionChanged;
            }
            if (entity.HasVector3(CommonNames.Velocity))
            {
                entity.GetVector3Attribute(CommonNames.Velocity).ValueChanged -= VelocityChanged;
            }
            if (entity.HasBool(CommonNames.Dead))
            {
                entity.GetBoolAttribute(CommonNames.Dead).ValueChanged -= DeadChanged;
            }

            base.OnDetached(entity);
        }
Esempio n. 2
0
        public override void OnDetached(AbstractEntity entity)
        {
            if (entity.HasVector3(CommonNames.Interactable))

            {
                entity.GetBoolAttribute(CommonNames.Interactable).ValueChanged -= InteractableChanged;
            }

            base.OnDetached(entity);
        }
Esempio n. 3
0
        public override void OnDetached(AbstractEntity entity)
        {
            Game.Instance.Simulation.CurrentUpdateQueue.AddUpdate(new RemoveRenderableUpdate((Renderable)Updatable));

            if (entity.HasVector3(CommonNames.Position))
            {
                entity.GetVector3Attribute(CommonNames.Position).ValueChanged -= PositionChanged;
            }
            if (entity.HasQuaternion(CommonNames.Rotation))
            {
                entity.GetQuaternionAttribute(CommonNames.Rotation).ValueChanged -= RotationChanged;
            }
            if (entity.HasVector3(CommonNames.Scale))
            {
                entity.GetVector3Attribute(CommonNames.Scale).ValueChanged -= ScaleChanged;
            }

            base.OnDetached(entity);
        }
        public override void OnAttached(AbstractEntity entity)
        {
            base.OnAttached(entity);

            if (entity.HasVector3(CommonNames.Position))
            {
                entity.GetVector3Attribute(CommonNames.Position).ValueChanged += PositionChanged;
            }

            Game.Instance.Simulation.CurrentUpdateQueue.AddUpdate(new AddRenderableUpdate((Renderable)Updatable));
        }
Esempio n. 5
0
        public override void OnAttached(AbstractEntity entity)
        {
            base.OnAttached(entity);

            if (entity.HasVector3(CommonNames.Scale))
            {
                entity.GetVector3Attribute(CommonNames.Scale).ValueChanged += ScaleChanged;
            }

            if (entity.HasQuaternion(CommonNames.Rotation))
            {
                entity.GetQuaternionAttribute(CommonNames.Rotation).ValueChanged += RotationChanged;
            }

            if (entity.HasVector3(CommonNames.Position))
            {
                entity.GetVector3Attribute(CommonNames.Position).ValueChanged += PositionChanged;
            }

            Game.Instance.Simulation.OnLevelLoaded             += LevelLoaded;
            Game.Instance.Simulation.EntityManager.EntityAdded += EntityAdded;

            Game.Instance.Simulation.CurrentUpdateQueue.AddUpdate(new AddRenderableUpdate((Renderable)Updatable));
        }
        public override void OnAttached(AbstractEntity entity)
        {
            Debug.Assert(entity.HasVector3(CommonNames.Position));

            this.island          = entity as Entity;
            this.constants       = Game.Instance.Simulation.EntityManager["island_constants"];
            this.playerConstants = Game.Instance.Simulation.EntityManager["player_constants"];

            if (!entity.HasAttribute(CommonNames.MaxHealth))
            {
                entity.AddFloatAttribute(CommonNames.MaxHealth, (entity.GetVector3(CommonNames.Scale).Length() * constants.GetFloat("scale_health_multiplier")));
            }
            entity.AddFloatAttribute(CommonNames.Health, entity.GetFloat(CommonNames.MaxHealth));

            hasFixedMovementPath = entity.GetBool("fixed");

            entity.AddVector3Attribute("repulsion_velocity", Vector3.Zero);
            entity.AddVector3Attribute("pushback_velocity", Vector3.Zero);
            entity.AddVector3Attribute("repositioning_velocity", Vector3.Zero);

            entity.AddStringAttribute("repulsed_by", "");
            entity.AddIntAttribute("players_on_island", 0);
            entity.AddIntAttribute("players_targeting_island", 0);

            // approximation of island's radius and height
            Vector3 scale = island.GetVector3(CommonNames.Scale);

            entity.AddFloatAttribute("height", scale.Y);
            scale.Y = 0;
            entity.AddFloatAttribute("radius", scale.Length());

            (entity as Entity).OnUpdate += OnUpdate;

            entity.GetProperty <CollisionProperty>("collision").OnContact += CollisionHandler;
//            ((Vector3Attribute)entity.GetAttribute("repulsion_velocity")).ValueChanged += RepulsionChangeHandler;
            entity.GetAttribute <StringAttribute>("repulsed_by").ValueChanged    += RepulsedByChangeHandler;
            entity.GetAttribute <IntAttribute>("players_on_island").ValueChanged += PlayersOnIslandChangeHandler;

            originalPosition = entity.GetVector3(CommonNames.Position);
        }