Beispiel #1
0
        /// <summary>
        ///     Detaches the client from an entity.
        /// </summary>
        public void DetachEntity()
        {
            var previous = ControlledEntity;

            if (ControlledEntity != null && ControlledEntity.Initialized)
            {
                ControlledEntity.GetComponent <EyeComponent>().Current = false;
                var transform = ControlledEntity.Transform;
                if (transform != null)
                {
                    transform.OnMove -= OnPlayerMoved;
                }
                ControlledEntity.SendMessage(null, new PlayerDetachedMsg());

                // notify ECS Systems
                ControlledEntity.EntityManager.RaiseEvent(this, new PlayerAttachSysMessage(null));
            }

            ControlledEntity = null;

            if (previous != null)
            {
                EntityDetached?.Invoke(new EntityDetachedEventArgs(previous));
            }
        }
Beispiel #2
0
    private void OnControlledCreated(ControlledEntity entity)
    {
        GameObject go =
            ArchetypeLibrary.Instance.Instantiate(
                entity.State.ArchetypeId);

        ControlledEntityBehaviour obj =
            go.GetComponent <ControlledEntityBehaviour>();

        obj.Entity = entity;
    }
Beispiel #3
0
        private void OnControllerAdded(IRailControllerServer controller)
        {
            ControlledEntity controlled = this.server.AddNewEntity <ControlledEntity>();

            controlled.State.ArchetypeId = 0;
            controller.GrantControl(controlled);
            controller.ScopeEvaluator = new GameScopeEvaluator(controlled);
            controller.UserData       = controlled;

            MimicEntity mimic = this.server.AddNewEntity <MimicEntity>();

            mimic.State.ArchetypeId = 2;
            mimic.Bind(controlled, 3.5f, 0.0f);
        }
        /// <summary>
        ///     Detaches the client from an entity.
        /// </summary>
        public void DetachEntity()
        {
            if (ControlledEntity != null && ControlledEntity.Initialized)
            {
                ControlledEntity.RemoveComponent <PlayerInputMoverComponent>();
                ControlledEntity.GetComponent <EyeComponent>().Current = false;
                var transform = ControlledEntity.Transform;
                if (transform != null)
                {
                    transform.OnMove -= OnPlayerMoved;
                }
                ControlledEntity.SendMessage(null, new PlayerDetachedMsg());

                // notify ECS Systems
                ControlledEntity.EntityManager.RaiseEvent(this, new PlayerAttachSysMessage(null));
            }
            ControlledEntity = null;

            EntityDetached?.Invoke(this, EventArgs.Empty);
        }
Beispiel #5
0
        private void OnControllerLeft(IRailControllerServer controller)
        {
            ControlledEntity controlled = (ControlledEntity)controller.UserData;

            this.server.DestroyEntity(controlled);
        }