public SpawnInitParams GetSpawnInitParams() { Dictionary <int, TransformDT> transforms = new Dictionary <int, TransformDT>(); var objectsIds = RootGameObject.GetComponentsInChildren <ObjectId>(); foreach (var objectId in objectsIds) { if (!transforms.ContainsKey(objectId.Id)) { transforms.Add(objectId.Id, objectId.gameObject.transform.ToTransformDT()); } } var spawn = new SpawnInitParams { ParentId = _parentId, IdLocation = WorldData.WorldLocationId, IdInstance = Id, IdObject = IdObject, IdServer = IdServer, Name = Name, Transforms = transforms }; return(spawn); }
private void SaveKinematics() { var rigidBodies = RootGameObject.GetComponentsInChildren <Rigidbody>(); foreach (Rigidbody rigidbody in rigidBodies) { _rigidBodyKinematicsDefaults.Add(rigidbody, rigidbody.isKinematic); } }
public void Delete() { List <ObjectBehaviourWrapper> childrens = RootGameObject.GetComponentsInChildren <ObjectBehaviourWrapper>().ToList(); childrens.Reverse(); JointBehaviour jointBehaviour = RootGameObject.GetComponent <JointBehaviour>(); if (jointBehaviour != null) { jointBehaviour.UnLockAndDisconnectPoints(); } foreach (var children in childrens) { ObjectController type = children.OwdObjectController; WrappersCollection.Remove(type.Id); foreach (ColliderController colliderController in type._colliderControllers) { colliderController.Destroy(); } foreach (InputController inputController in type._inputControllers.Values) { inputController.Destroy(); } type.OnDestroy?.Invoke(); type.Entity?.Destroy(); if (type.Uiid != null) { Object.Destroy(type.Uiid.gameObject); } if (type.UiObject != null) { Object.Destroy(type.UiObject.gameObject); } if (type.EntityParentLine != null) { Object.Destroy(type.EntityParentLine.gameObject.Value); type.EntityParentLine.Destroy(); } type.RootGameObject.DestroyGameObject(); type.Dispose(); } ProjectData.ObjectsAreChanged = true; }
private void AddBehaviours() { var behaviours = RootGameObject.GetComponentsInChildren <MonoBehaviour>(true); bool haveRootInputControl = false; bool haveJoints = false; foreach (MonoBehaviour behaviour in behaviours) { if (behaviour == null) { continue; } bool haveInputControlInObject; bool haveInputControlInRoot; AddInputControl(behaviour, out haveInputControlInObject, out haveInputControlInRoot); if (behaviour is JointPoint) { haveJoints = true; } if (haveInputControlInObject) { haveRootInputControl = true; } AddGameModeSwitchControls(behaviour); AddCollidersAware(behaviour); AddObjectTransforms(behaviour); } if (haveJoints) { AddJointBehaviour(); } if (!haveRootInputControl) { var inputController = new InputController(this, RootGameObject, photonView, true); _inputControllers.Add(-1, inputController); LogManager.GetCurrentClassLogger().Info("Added input controller on " + RootGameObject.name); } Entity.AddInputControls(_inputControllers); }
public List <ObjectController> GetChildrens() { List <ObjectController> result = new List <ObjectController>(); List <ObjectBehaviourWrapper> childrens = RootGameObject.GetComponentsInChildren <ObjectBehaviourWrapper>().ToList(); foreach (var children in childrens) { if (children.OwdObjectController.Id == Id) { continue; } result.Add(children.OwdObjectController); } return(result); }
private void Create() { var monobehaviours = RootGameObject.GetComponentsInChildren <MonoBehaviour>(); foreach (MonoBehaviour monoBehaviour in monobehaviours) { if (monoBehaviour == null) { continue; } MethodInfo method = monoBehaviour.GetType() .GetMethod("Create", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); if (method != null && method.GetParameters().Length == 0) { method.Invoke(monoBehaviour, null); } } }