コード例 #1
0
    private void HandleWorldObjectCollision(GameObject colObj)
    {
        BaseWorldObject baseObjComp = colObj.GetComponent <BaseWorldObject>();

        Tagger tagger = baseObjComp.tagger;

        if (tagger.tags.Contains(TagTypes.Obstacle))
        {
            // we hit an obstacle so switch direction
            SwitchDirection();
        }
    }
コード例 #2
0
        private void CreateNew_WorldObject()
        {
            WorldObjectScript worldObjectScript = target as WorldObjectScript;
            PickableScript    pickableScript    = target as PickableScript;
            ActorScript       actorScript       = target as ActorScript;

            var dir  = NewFolder(target.gameObject.name);
            var path = $"{dir}/{target.gameObject.name}.prefab";

            var prefab1 = PrefabUtility.SaveAsPrefabAssetAndConnect(target.gameObject, path, InteractionMode.UserAction);

            BaseWorldObject baseWorldObject = new BaseWorldObject();

            baseWorldObject.ID        = worldObjectScript.Get_ObjectRefData().formID.BaseID;
            baseWorldObject.gameModel = prefab1;

            objectDatabase.Data.allBaseWorldObjects.Add(baseWorldObject);
        }
コード例 #3
0
        /// <summary>
        /// Populates the given <see cref="BaseWorldObject"/> with the next available global ID.
        /// </summary>
        /// <param name="obj">A <see cref="BaseWorldObject"/>. On return, its <see cref="BaseWorldObject.ObjectID"/> will
        /// be set to a valid identifier if it wasn't already.</param>
        /// <remarks>All instantiated objects in the world have a sequential identifier. This helper method
        /// just manages the assignment of these identifiers in a thread-safe way.</remarks>
        public static void NextObjectID(BaseWorldObject obj)
        {
            // The idea behind this constant is to give a window where we need to restart at 0. Theoretically
            // by the point you reach almost 2 billion world objects instantiated, the ones at the bottom are
            // long gone, but you may need to adjust to your needs.
            const int ROLLOVER = Int32.MaxValue - 100000;

            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            if (obj.ObjectID == BaseWorldObject.OBJECT_ID_INVALID)
            {
                obj.ObjectID = Interlocked.Increment(ref lastObjID);
                if (lastObjID > ROLLOVER)
                {
                    Interlocked.Exchange(ref lastObjID, 0);
                }
            }
        }