Ejemplo n.º 1
0
        public ObjectController(InitObjectParams initObjectParams)
        {
            _context = Contexts.sharedInstance;
            Entity   = _context.game.CreateEntity();
            _config  = initObjectParams.Config;

            RootGameObject     = initObjectParams.RootGameObject;
            gameObject         = initObjectParams.Asset;
            Id                 = initObjectParams.Id;
            IdObject           = initObjectParams.IdObject;
            IdLocation         = initObjectParams.IdLocation;
            IdServer           = initObjectParams.IdServer;
            Name               = initObjectParams.Name;
            WrappersCollection = initObjectParams.WrappersCollection;

            int instanceId = Id;

            this.RegisterMeInLocation(ref instanceId);
            Id = instanceId;
            SetName(Name);

            if (initObjectParams.Parent != null)
            {
                SetParent(initObjectParams.Parent);
            }

            RootGameObject.AddComponent <ObjectBehaviourWrapper>().OwdObjectController = this;

            AddBehaviours();
            AddWrapper();
            SaveKinematics();

            Entity.AddId(Id);
            Entity.AddIdServer(IdServer);
            Entity.AddIdObject(IdObject);
            Entity.AddRootGameObject(RootGameObject);
            Entity.AddGameObject(gameObject);

            Rigidbody rigidbody = gameObject.GetComponent <Rigidbody>();

            if (rigidbody != null)
            {
                Entity.AddRigidbody(rigidbody);
            }

            Collider collider = gameObject.GetComponentInChildren <Collider>();

            if (collider)
            {
                Entity.AddCollider(collider);
            }

            ApplyGameMode(WorldData.GameMode, WorldData.GameMode);
            RequestManager.Instance.StartCoroutine(ExecuteSwitchGameModeDelayedCoroutine());

            Create();
        }
Ejemplo n.º 2
0
        private void AddJointBehaviour()
        {
            if (RootGameObject.GetComponent <JointBehaviour>() != null)
            {
                return;
            }

            _jointBehaviour = RootGameObject.AddComponent <JointBehaviour>();
            _jointBehaviour.Init();
            LogManager.GetCurrentClassLogger().Info("Added joint behaviour on " + RootGameObject.name);
        }
Ejemplo n.º 3
0
 public static void Init()
 {
     _instance = RootGameObject.AddComponent <UpdateDriver>();
     Debug.Log($"{nameof(UpdateDriver)} loaded on {_instance.name}");
 }