public static void UpdateData(this IMutableGameObjectData data, IGameObjectData update)
 {
     data.CreatedBy       = update.CreatedBy ?? data.CreatedBy;
     data.Flags           = update.Flags ?? data.Flags;
     data.ParentRotation  = update.ParentRotation ?? data.ParentRotation;
     data.FactionTemplate = update.FactionTemplate ?? data.FactionTemplate;
     data.State           = update.State ?? data.State;
     data.TypeID          = update.TypeID ?? data.TypeID;
     data.PercentHealth   = update.PercentHealth ?? data.PercentHealth;
     data.DisplayID       = update.DisplayID ?? data.DisplayID;
     data.ArtKit          = update.ArtKit ?? data.ArtKit;
     data.Level           = update.Level ?? data.Level;
 }
        public static GameObject GetGameObject(string value, IIDData idData, IGameObjectData gameObjectData)
        {
            switch (value)
            {
            case "this":
                return(gameObjectData.GetGameObject());

            case "parent":
                var parent = gameObjectData.GetGameObject().transform.parent;
                return(parent != null ? parent.gameObject : null);

            default:
                return(idData.GetObjectByID(value));
            }
        }
Beispiel #3
0
        public static void UpdateData(this UpdateValuesObjectDataFields fields, IGameObjectData data)
        {
            var go = fields.Gameobject ??= new();

            if (data.CreatedBy != null)
            {
                go.CreatedBy = data.CreatedBy;
            }
            go.Flags = data.Flags;
            if (data.ParentRotation.HasValue)
            {
                go.ParentRotation = data.ParentRotation;
            }
            go.FactionTemplate = data.FactionTemplate;
            go.State           = data.State;
            go.TypeID          = data.TypeID;
            go.PercentHealth   = data.PercentHealth;
            go.DisplayID       = data.DisplayID;
            go.ArtKit          = data.ArtKit;
            go.Level           = data.Level;
        }
        public static Component GetComponent(string value, Type componentType, IIDData idData, IGameObjectData gameObjectData)
        {
            var gameObject = GetGameObject(value, idData, gameObjectData);

            return(gameObject != null?gameObject.GetComponentInParent(componentType) : null);
        }
 public virtual IGameObjectData ReadUpdateGameObjectData(Packet packet, IGameObjectData existingData, params object[] indexes)
 {
     return(existingData);
 }
 public GameObject() : base()
 {
     GameObjectData = new GameObjectData(this);
 }
        public static bool SetComponent(PropertyInfo p, object obj, string value, IIDData idData, IGameObjectData gameObjectData, IResFoldersData resFolderData)
        {
            if (p.PropertyType.GetGeneration(typeof(Component)) == -1)
            {
                return(false);
            }

            if (value.IndexOf("id:") == 0)
            {
                idData.WaitForID(value.Replace("id:", ""), go => {
                    var c = go.GetComponent(p.PropertyType);
                    if (c != null)
                    {
                        p.SetValue(obj, c, null);
                    }
                }
                                 );
                return(true);
            }

            object component = ValueGetter.GetComponent(value, p.PropertyType, idData, gameObjectData);

            if (component == null)
            {
                component = ValueGetter.GetResObject(value, p.PropertyType, resFolderData.GetResFolders());
            }

            if (component != null)
            {
                p.SetValue(obj, component, null);
            }

            return(true);
        }
        public static bool SetGameObject(PropertyInfo p, object obj, string value, IIDData idData, IGameObjectData gameObjectData, IResFoldersData resFoldersData)
        {
            if (p.PropertyType != typeof(GameObject))
            {
                return(false);
            }

            if (value.IndexOf("id:") == 0)
            {
                idData.WaitForID(value.Replace("id:", ""), go => p.SetValue(obj, go, null));
                return(true);
            }

            var gameObject = ValueGetter.GetGameObject(value, idData, gameObjectData);

            if (gameObject == null)
            {
                gameObject = ValueGetter.GetResObject(value, typeof(GameObject), resFoldersData.GetResFolders()) as GameObject;
            }

            if (gameObject != null)
            {
                p.SetValue(obj, gameObject, null);
            }

            return(true);
        }