// nullable public static NetworkSkin Deserialize(DataSerializer s, IPrefabCollection prefabCollection, NetworkSkinLoadErrors errors) { var prefab = prefabCollection.FindPrefab <NetInfo>(s.ReadUniqueString(), errors); var modifiersCount = s.ReadInt32(); var modifiers = new List <NetworkSkinModifier>(); for (var m = 0; m < modifiersCount; m++) { var modifier = NetworkSkinModifier.Deserialize(s, prefabCollection, errors); if (modifier != null) { modifiers.Add(modifier); } } // We are checking if the prefab is null after all the modifiers are deserialized! // This is important for the deserialization of the next items! if (prefab == null) { return(null); } return(new NetworkSkin(prefab, modifiers)); }
public static StreetLightModifier DeserializeImpl(DataSerializer s, IPrefabCollection prefabCollection, NetworkSkinLoadErrors errors) { var streetLight = prefabCollection.FindPrefab <PropInfo>(s.ReadUniqueString(), errors); var repeatDistance = s.ReadFloat(); return(new StreetLightModifier(streetLight, repeatDistance)); }
// nullable public static NetworkSkinModifier Deserialize(DataSerializer s, IPrefabCollection prefabCollection, NetworkSkinLoadErrors errors) { var type = (NetworkSkinModifierType)s.ReadUInt8(); switch (type) { case NetworkSkinModifierType.TerrainSurface: return(TerrainSurfaceModifier.DeserializeImpl(s, errors)); case NetworkSkinModifierType.Color: return(ColorModifier.DeserializeImpl(s, errors)); case NetworkSkinModifierType.StreetLight: return(StreetLightModifier.DeserializeImpl(s, prefabCollection, errors)); case NetworkSkinModifierType.Tree: return(TreeModifier.DeserializeImpl(s, prefabCollection, errors)); case NetworkSkinModifierType.Pillar: return(PillarModifier.DeserializeImpl(s, prefabCollection, errors)); case NetworkSkinModifierType.Catenary: return(CatenaryModifier.DeserializeImpl(s, prefabCollection, errors)); default: return(null); } }
public static TreeModifier DeserializeImpl(DataSerializer s, IPrefabCollection prefabCollection, NetworkSkinLoadErrors errors) { var position = (LanePosition)s.ReadInt32(); var tree = prefabCollection.FindPrefab <TreeInfo>(s.ReadUniqueString(), errors); var repeatDistance = s.ReadFloat(); return(new TreeModifier(position, tree, repeatDistance)); }
public static PillarModifier DeserializeImpl(DataSerializer s, IPrefabCollection prefabCollection, NetworkSkinLoadErrors errors) { var type = (PillarType)s.ReadInt32(); var pillar = prefabCollection.FindPrefab <BuildingInfo>(s.ReadUniqueString(), errors); return(new PillarModifier(type, pillar)); }
// can be overridden for testing protected void Initialize() { Modifiers = new List<NetworkSkinModifier>(); Errors = new NetworkSkinLoadErrors(); PrefabCollection = new GamePrefabCollection(); NetManager = new GameNetManager(); }
// can be overridden for testing protected virtual void Initialize() { // this must be set here, as the constructor is not called on deserialization AppliedSkins = NetworkSkinManager.instance.AppliedSkins; SegmentSkins = NetworkSkinManager.SegmentSkins; NodeSkins = NetworkSkinManager.NodeSkins; PrefabCollection = new GamePrefabCollection(); NetManager = new GameNetManager(); }
public static CatenaryModifier DeserializeImpl(DataSerializer s, IPrefabCollection prefabCollection, NetworkSkinLoadErrors errors) { var catenary = prefabCollection.FindPrefab <PropInfo>(s.ReadUniqueString(), errors); return(new CatenaryModifier(catenary)); }