Ejemplo n.º 1
0
        public static WorldObjectData ReadWorldObjectData(this NetworkReader reader)
        {
            WorldObjectTypes objectType = (WorldObjectTypes)reader.ReadInt32();
            uint             key        = reader.ReadUInt32();
            bool             spawned    = reader.ReadBoolean();

            if (objectType == WorldObjectTypes.ZonneBloem)
            {
                TreeObjectData data = new TreeObjectData();
                data.SetObjectType(objectType);
                data.SetKey(key);
                data.SetInstantiated(spawned);
                data.SetTreeState((TreeObjectData.TreeStates)reader.ReadByte());
                return(data);
            }


            //Tree type.
            if (objectType == WorldObjectTypes.Artic)
            {
                IslandObjectData data = new IslandObjectData();
                data.SetObjectType(objectType);
                data.SetKey(key);
                data.SetInstantiated(spawned);
                data.SetTreeState((IslandObjectData.TreeStates)reader.ReadByte());
                return(data);
            }
            //Tree type.
            if (objectType == WorldObjectTypes.Dessert)
            {
                IslandObjectData data = new IslandObjectData();
                data.SetObjectType(objectType);
                data.SetKey(key);
                data.SetInstantiated(spawned);
                data.SetTreeState((IslandObjectData.TreeStates)reader.ReadByte());
                return(data);
            }
            //Tree type.
            if (objectType == WorldObjectTypes.Jungle)
            {
                IslandObjectData data = new IslandObjectData();
                data.SetObjectType(objectType);
                data.SetKey(key);
                data.SetInstantiated(spawned);
                data.SetTreeState((IslandObjectData.TreeStates)reader.ReadByte());
                return(data);
            }

            //Not supported by serializer.
            else
            {
                Debug.LogError("Serializer not written for type " + objectType.ToString());
                return(null);
            }
        }
Ejemplo n.º 2
0
 public override void UpdateData(WorldObjectData data)
 {
     Data = (TreeObjectData)data;
     ApplyStateVisuals();
 }