Ejemplo n.º 1
0
        void enable_circle_indicator(bool enable)
        {
            if (enable == false && circle_indicator == null)
            {
                return;
            }
            if (enable && circle_indicator == null)
            {
                LineSet lines = new LineSet();
                lines.UseFixedNormal = true;
                lines.FixedNormal    = Vector3f.AxisY;
                DCurve3 curve = new DCurve3(Polygon2d.MakeCircle(gizmoInitialRadius, 64), 0, 2);
                lines.Curves.Add(curve);
                lines.Width     = 1.0f;
                lines.WidthType = LineWidthType.Pixel;
                lines.Segments.Add(
                    new Segment3d(Vector3d.Zero, gizmoInitialRadius * diagonals[nRotationAxis]));
                lines.Color      = Colorf.DimGrey;
                circle_indicator = new fLineSetGameObject(new GameObject(), lines, "circle");
                circle_indicator.SetLayer(FPlatform.WidgetOverlayLayer, true);

                circle_indicator.SetLocalRotation(Quaternionf.FromTo(Vector3f.AxisY, Frame3f.Identity.GetAxis(nRotationAxis)));
                RootGameObject.AddChild(circle_indicator, false);
            }
            circle_indicator.SetVisible(enable);
        }
Ejemplo n.º 2
0
 public void InitializeTracking(Cockpit fromExisting)
 {
     RootGameObject.SetPosition(fromExisting.RootGameObject.GetPosition());
     RootGameObject.SetRotation(fromExisting.RootGameObject.GetRotation());
     //RootGameObject.transform.position = fromExisting.RootGameObject.transform.position;
     //RootGameObject.transform.rotation = fromExisting.RootGameObject.transform.rotation;
 }
Ejemplo n.º 3
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.Add(RootGameObjectName, RootGameObject.ExportYAML(container));
            return(node);
        }
Ejemplo n.º 4
0
        public GameObject Parse(string LevelName)
        {
            this.LevelName = LevelName;
            Logger.Log.Debug("Parsing " + LevelName + " from " + _filePath + " file");
            RootGameObject RootObject = new RootGameObject();

            JObject LevelObject = JObject.Parse(File.ReadAllText(_filePath)).GetValue(LevelName).ToObject <JObject>();

            if (LevelObject == null)
            {
                throw new ArgumentNullException(_filePath + " does not containt key " + LevelName);
            }

            RootObject.Name = LevelObject.GetValue("Name").ToString();
            RootObject.Type = LevelObject.GetValue("Type").ToString();
            Level.GetCurrentLevel().RootGameObject = RootObject;

            for (int i = 0; i < LevelObject.GetValue("Child").Count(); i++)
            {
                RootObject.AddChild(ParseGameObject(LevelObject.GetValue("Child")[i] as JObject));
            }

            Logger.Log.Debug("File " + _filePath + "parsed successfully");

            return(RootObject);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
    private GameObject GetBlockUnderMouse()
    {
        Camera camera = CameraExtensions.FindCameraUnderMouse();

        if (camera == null)
        {
            return(null);
        }

        Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;

        if (!Physics.Raycast(ray, out hitInfo))
        {
            return(null);
        }

        GameObject gameObject = RootGameObject.GetRoot(hitInfo.collider.gameObject);

        if (Tags.PALETTE_BLOCK.HasTag(gameObject))
        {
            return(gameObject);
        }

        return(null);
    }
Ejemplo n.º 7
0
 public virtual void SetLayer(int nLayer)
 {
     RootGameObject.SetLayer(nLayer);
     foreach (var go in GameObjects)
     {
         UnityUtil.SetLayerRecursive(go, nLayer);
     }
 }
Ejemplo n.º 8
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node   = base.ExportYAMLRoot(container);
            PrefabLayout    layout = container.ExportLayout.Prefab;

            node.Add(layout.RootGameObjectName, RootGameObject.ExportYAML(container));
            return(node);
        }
Ejemplo n.º 9
0
 public void Destroy()
 {
     while (vUIElements.Count > 0)
     {
         RemoveUIElement(vUIElements[0], true);
     }
     RootGameObject.SetParent(null);
     RootGameObject.Destroy();
 }
Ejemplo n.º 10
0
        public override void Read(EndianStream stream)
        {
            base.Read(stream);

            ParentPrefab.Read(stream);
            RootGameObject.Read(stream);
            IsPrefabParent = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align64);
        }
Ejemplo n.º 11
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.º 12
0
        private void SaveKinematics()
        {
            var rigidBodies = RootGameObject.GetComponentsInChildren <Rigidbody>();

            foreach (Rigidbody rigidbody in rigidBodies)
            {
                _rigidBodyKinematicsDefaults.Add(rigidbody, rigidbody.isKinematic);
            }
        }
Ejemplo n.º 13
0
        public JointData GetJointData()
        {
            JointData jointData;

            JointBehaviour jointBehaviour = RootGameObject.GetComponent <JointBehaviour>();

            if (jointBehaviour == null)
            {
                return(null);
            }

            jointData = new JointData {
                JointConnetionsData = new Dictionary <int, JointConnetionsData>()
            };

            foreach (JointPoint jointPoint in jointBehaviour.JointPoints)
            {
                if (jointPoint.IsFree)
                {
                    continue;
                }

                var objectId = jointPoint.gameObject.GetComponent <ObjectId>();

                if (objectId == null)
                {
                    LogManager.GetCurrentClassLogger().Error($"Joint point {jointPoint.gameObject} have no object id");

                    continue;
                }

                var connectedJointPointObjectId = jointPoint.ConnectedJointPoint.gameObject.GetComponent <ObjectId>();

                if (connectedJointPointObjectId == null)
                {
                    LogManager.GetCurrentClassLogger()
                    .Error($"Connected joint point {jointPoint.ConnectedJointPoint.gameObject} have no object id");

                    continue;
                }

                int jointPointId = objectId.Id;
                int connectedObjectInstanceId   = jointPoint.ConnectedJointPoint.JointBehaviour.Wrapper.GetInstanceId();
                int connectedObjectJointPointId = connectedJointPointObjectId.Id;

                jointData.JointConnetionsData.Add(jointPointId,
                                                  new JointConnetionsData
                {
                    ConnectedObjectInstanceId   = connectedObjectInstanceId,
                    ConnectedObjectJointPointId = connectedObjectJointPointId,
                    ForceLocked = jointPoint.IsForceLocked
                });
            }

            return(jointData);
        }
Ejemplo n.º 14
0
        public override void Read(AssetStream stream)
        {
            base.Read(stream);

            ParentPrefab.Read(stream);
            RootGameObject.Read(stream);
            IsPrefabParent = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align64);
            throw new NotSupportedException("Currently EditorExtension's PrefabInternal field doesn't support Engine's prefabs");
        }
Ejemplo n.º 15
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            Modification.Read(reader);
            SourcePrefab.Read(reader);
            RootGameObject.Read(reader);
            IsPrefabParent = reader.ReadBoolean();
            reader.AlignStream(AlignType.Align64);
        }
Ejemplo n.º 16
0
        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;
        }
Ejemplo n.º 17
0
        public override IEnumerable <Object> FetchDependencies(ISerializedFile file, bool isLog = false)
        {
            foreach (Object asset in base.FetchDependencies(file, isLog))
            {
                yield return(asset);
            }

            yield return(ParentPrefab.GetAsset(file));

            yield return(RootGameObject.GetAsset(file));
        }
Ejemplo n.º 18
0
 public string GetName(ISerializedFile file)
 {
     if (IsModificationsFormat(file.Version))
     {
         return(RootGameObject.GetAsset(file).Name);
     }
     else
     {
         return(Name);
     }
 }
Ejemplo n.º 19
0
 public string GetName(IAssetContainer file)
 {
     if (file.Layout.PrefabInstance.IsModificationFormat)
     {
         return(RootGameObject.GetAsset(file).Name);
     }
     else
     {
         return(Name);
     }
 }
Ejemplo n.º 20
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(GetSerializedVersion(container.Version));
            node.Add("m_Modification", Modification.ExportYAML(container));
            node.Add("m_ParentPrefab", ParentPrefab.ExportYAML(container));
            node.Add("m_RootGameObject", RootGameObject.ExportYAML(container));
            node.Add("m_IsPrefabParent", IsPrefabParent);
            return(node);
        }
Ejemplo n.º 21
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.º 22
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(GetSerializedVersion(container.ExportVersion));
            node.Add(ModificationName, Modification.ExportYAML(container));
            node.Add(ParentPrefabName, SourcePrefab.ExportYAML(container));
            node.Add(RootGameObjectName, RootGameObject.ExportYAML(container));
            node.Add(IsPrefabParentName, IsPrefabParent);
            return(node);
        }
Ejemplo n.º 23
0
 virtual public void SetLocalScale(Vector3f scale)
 {
     if (SupportsScaling)
     {
         RootGameObject.SetLocalScale(scale);
         increment_timestamp();
         if (OnTransformModified != null)
         {
             OnTransformModified(this);
         }
     }
 }
Ejemplo n.º 24
0
        public void AddWrapper()
        {
            IWrapperAware wrapperAware = RootGameObject.GetComponentInChildren <IWrapperAware>();

            if (wrapperAware != null)
            {
                Wrapper wrapper = wrapperAware.Wrapper();
                WrappersCollection.Add(Id, wrapper);
                Entity.AddWrapper(wrapper);
                wrapper.InitEntity(Entity);
            }
        }
Ejemplo n.º 25
0
 public override void Disconnect()
 {
     if (circle_indicator != null)
     {
         circle_indicator.Destroy();
     }
     if (snap_indicator != null)
     {
         circle_indicator.Destroy();
     }
     RootGameObject.Destroy();
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Init the scene.
        /// </summary>
        public GameScene()
        {
            // create physical world
            _physics = new Core.Physics.PhysicsWorld();

            // create user interface
            UserInterface = GeonBitMain.Instance.UiEnabled ? new UI.UserInterface() : null;

            // create scene root
            Root = new RootGameObject(this, SceneNodeType.Simple);
            Root.SceneNode.DisableCulling = true;
        }
Ejemplo n.º 27
0
    protected override void DoActivate(Collider collider)
    {
        originalBlock = RootGameObject.GetRoot(collider.gameObject);
        originalBlock.SetActive(false);

        moveCollisionChecker       = Instantiate(originalBlock);
        moveCollisionChecker.name += "_Checker";

        moveFeedback       = Instantiate(originalBlock);
        moveFeedback.name += "_Feedback";

        Initialise(moveFeedback, moveCollisionChecker);
    }
Ejemplo n.º 28
0
 /// <summary>
 /// Changes the camera placement when the Model has changed.
 /// </summary>
 protected virtual void ModelTransformChanged()
 {
     if (RootGameObject != null)
     {
         var bounds = RootGameObject.CalculateBounds();
         Camera.main.FitToBounds(bounds, CameraDistanceRatio);
         CameraDistance = Camera.main.transform.position.magnitude;
         CameraPivot    = bounds.center;
         Skybox.transform.localScale = bounds.size.magnitude * SkyboxScale * Vector3.one;
         InputMultiplier             = bounds.size.magnitude * InputMultiplierRatio;
         CameraAngle = Vector2.zero;
     }
 }
Ejemplo n.º 29
0
    /**
     * Retrieve the nearest root game object relative to the given one. If there
     * is no root game object that parents the given game object, the game object
     * itself is returned.
     */
    public static GameObject GetRoot(GameObject gameObject)
    {
        RootGameObject root = gameObject.GetComponentInParent <RootGameObject>();

        if (root == null)
        {
            return(gameObject);
        }
        else
        {
            return(root.gameObject);
        }
    }
Ejemplo n.º 30
0
        public override IEnumerable <Object> FetchDependencies(ISerializedFile file, bool isLog = false)
        {
            foreach (Object @object in base.FetchDependencies(file, isLog))
            {
                yield return(@object);
            }

            if (!ParentPrefab.IsNull)
            {
                yield return(ParentPrefab.GetObject(file));
            }
            yield return(RootGameObject.GetObject(file));
        }