public override void seasonUpdate(string season, bool onLoad = false) { // Hide the terrain features from the seasonal update so that grass // is not removed in winter. NetVector2Dictionary <TerrainFeature, NetRef <TerrainFeature> > hold = new NetVector2Dictionary <TerrainFeature, NetRef <TerrainFeature> > (); hold.MoveFrom(terrainFeatures); base.seasonUpdate(season, onLoad); terrainFeatures.MoveFrom(hold); // Handle the terrain features separately, preserving the grass. for (int num = terrainFeatures.Count() - 1; num >= 0; --num) { TerrainFeature tf = terrainFeatures.Values.ElementAt(num); if (tf is Grass) { tf.loadSprite(); } else if (tf.seasonUpdate(onLoad)) { terrainFeatures.Remove(terrainFeatures.Keys.ElementAt(num)); } } }
private void process() { if (!create) { //Log.Async(Game1.gameMode + " " + ((Multiplayer.server != null) ? (Multiplayer.server.playing?"true":"false") : "NOTSERVER")+" "+((Game1.currentLoader!=null)?Game1.currentLoader.Current:-1)); //Log.Async("Want " + location+" "+Multiplayer.locations.Count); //foreach (KeyValuePair<string,LocationCache> cache in Multiplayer.locations) Log.Async("\tLoc: " + cache.Key + " " + cache.Value+" "+cache.Value.loc); if (!Multiplayer.locations.ContainsKey(location)) { return; } Multiplayer.locations[location].destroyTerrainFeature(new Vector2(posX, posY)); return; } // See whining at DebrisPacket.process Type[] featureTypes = new Type[] { typeof(TerrainFeature), typeof(Grass), typeof(DiggableWall), typeof(HoeDirt), typeof(Flooring), typeof(FruitTree), typeof(LargeTerrainFeature), typeof(Quartz), typeof(ResourceClump), typeof(Stalagmite), typeof(Tree), typeof(CosmeticPlant), typeof(Bush), typeof(GiantCrop), }; TerrainFeature tf = null; try { foreach (Type type in featureTypes) { if (featureStr.IndexOf("<" + type.Name) != -1) { tf = (TerrainFeature) new XmlSerializer(type).Deserialize(Util.stringStream(featureStr)); break; } } if (tf == null) { int begin = featureStr.IndexOf("<"); string type = featureStr.Substring(begin + 1, featureStr.IndexOf(" xmlns") - begin - 1); Log.warn("!!! An unknown terrain feature type (" + type + ") was created and received by us."); return; } } catch (Exception e) { Log.error("Exception deserializing terrain feature: " + e); } tf.loadSprite(); Multiplayer.locations[location].addTerrainFeature(new Vector2(posX, posY), tf); }