void IEnumerator.Reset() { _base = _dict.baseDict.Values.GetEnumerator(); _overlay = _dict.overlayDict.GetEnumerator(); _current = null; _done = false; }
void IEnumerator.Reset() { _base = _dict.baseDict.Keys.GetEnumerator(); _overlay = _dict.overlayDict.GetEnumerator(); _current = Vector2.Zero; _done = false; }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="field">The field to watch.</param> public NetDictionaryWatcher(NetDictionary <TKey, TValue, TField, TSerialDict, TSelf> field) { this.Field = field; field.OnValueAdded += this.OnValueAdded; field.OnValueRemoved += this.OnValueRemoved; }
void IEnumerator.Reset() { _base = _dict.baseDict.Pairs.GetEnumerator(); _overlay = _dict.overlayDict.GetEnumerator(); _current = default(KeyValuePair <Vector2, Object>); _done = false; }
public Enumerator(OverlaidDictionary dict) { _dict = dict; _base = _dict.baseDict.Values.GetEnumerator(); _overlay = _dict.overlayDict.GetEnumerator(); _current = null; _done = false; }
public Enumerator(OverlaidDictionary dict) { _dict = dict; _base = _dict.baseDict.Pairs.GetEnumerator(); _overlay = _dict.overlayDict.GetEnumerator(); _current = default(KeyValuePair <Vector2, Object>); _done = false; }
public Enumerator(OverlaidDictionary dict) { _dict = dict; _base = _dict.baseDict.Keys.GetEnumerator(); _overlay = _dict.overlayDict.GetEnumerator(); _current = Vector2.Zero; _done = false; }
public virtual void Deserialize(NetDataReader reader) { if (extraVariables == null) { this.extraVariables = new NetDictionary <NetString, NetString>(); } this.extraVariables.Deserialize(reader); this.GUID = reader.GetGuid(); }
public virtual void Serialize(NetDataWriter writer) { if (extraVariables == null) { this.extraVariables = new NetDictionary <NetString, NetString>(); } this.extraVariables.Serialize(writer); writer.Put(this.GUID); }
/// <summary> /// Adds an extra variable to the net class. /// </summary> /// <param name="Key"></param> /// <param name="obj"></param> public virtual void addExtraVariable(string Key, object obj) { NetString str = GameManager.Self.serializer.ToJSONString(obj); if (this.extraVariables == null) { this.extraVariables = new NetDictionary <NetString, NetString>(); } this.extraVariables.Add(Key, str); }
static void SimpleApplyModifier(NetDictionary <DBReference <Tag>, FInt> dict, Tag source, Tag target, FInt change, Dictionary <Tag, float> multiplier, List <Multitype <long, Tag, FInt, bool> > changelog) { FInt changeMP = change * multiplier.MHGetValueOrDefault(target, 1f); if (dict.ContainsKey(target)) { dict[target] += changeMP; } else { dict[target] = changeMP; } if (changelog != null) { changelog.Add(new Multitype <long, Tag, FInt, bool>(DescriptionInfoUtils.GetInfoID(source.descriptionInfo), target, change, false)); } }
/// <summary> /// Checks for saplings that are growth stage 1 despite being in the shade of another tree. /// Uses an unedited version of the location check StardewValley.TerrainFeatures.Tree.dayUpdate so saplings cant grow when tree stumps are in the way. /// </summary> /// <param name="tree">current sapling</param> /// <param name="location">ingame location (e.g. farm)</param> /// <param name="tileLocation">position in said location</param> public void RevertSaplingGrowthInShade(Tree tree, GameLocation location, Vector2 tileLocation) { if (tree.growthStage.Value != 1 || !treeOverhaulConfig.StopShadeSaplingGrowth) { return; } Rectangle growthRect = new Rectangle((int)((tileLocation.X - 1f) * 64f), (int)((tileLocation.Y - 1f) * 64f), 192, 192); using (NetDictionary <Vector2, TerrainFeature, NetRef <TerrainFeature>, SerializableDictionary <Vector2, TerrainFeature>, NetVector2Dictionary <TerrainFeature, NetRef <TerrainFeature> > > .PairsCollection.Enumerator enumerator = location.terrainFeatures.Pairs.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <Vector2, TerrainFeature> t = enumerator.Current; if (t.Value is Tree && !t.Value.Equals(this) && ((Tree)t.Value).growthStage >= 5 && t.Value.getBoundingBox(t.Key).Intersects(growthRect)) { tree.growthStage.Set(0); return; } } } }
/// <summary> /// Adjusts tree and mushroom tree growth depending on settings like growing them in the winter. /// Uses a slightly edited version of the growth call of StardewValley.TerrainFeatures.Tree.dayUpdate. /// </summary> /// <param name="tree">current tree</param> /// <param name="location">ingame location (e.g. farm)</param> /// <param name="tileLocation">position in said location</param> public void GrowTree(Tree tree, GameLocation location, Vector2 tileLocation) { Rectangle growthRect = new Rectangle((int)((tileLocation.X - 1f) * 64f), (int)((tileLocation.Y - 1f) * 64f), 192, 192); string s = location.doesTileHaveProperty((int)tileLocation.X, (int)tileLocation.Y, "NoSpawn", "Back"); if (s != null && (s.Equals("All") || s.Equals("Tree") || s.Equals("True"))) { return; } if (tree.growthStage == 4 || treeOverhaulConfig.StopShadeSaplingGrowth) { using (NetDictionary <Vector2, TerrainFeature, NetRef <TerrainFeature>, SerializableDictionary <Vector2, TerrainFeature>, NetVector2Dictionary <TerrainFeature, NetRef <TerrainFeature> > > .PairsCollection.Enumerator enumerator = location.terrainFeatures.Pairs.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <Vector2, TerrainFeature> t = enumerator.Current; if (t.Value is Tree && !t.Value.Equals(this) && ((Tree)t.Value).growthStage >= 5 && t.Value.getBoundingBox(t.Key).Intersects(growthRect)) { return; } } } } if (tree.growthStage == 0 && location.objects.ContainsKey(tileLocation)) { return; } if (Game1.random.NextDouble() < 0.2 || tree.fertilized.Value) { tree.growthStage.Set(tree.growthStage.Value + 1); } }
public virtual void Update(GameLocation currentLocation) { NetDictionary <string, bool, NetBool, SerializableDictionary <string, bool>, NetStringDictionary <bool, NetBool> > .KeysCollection activeCues = currentLocation.netAudio.ActiveCues; foreach (string cue3 in activeCues) { if (!playingCues.ContainsKey(cue3)) { playingCues[cue3] = Game1.soundBank.GetCue(cue3); playingCues[cue3].Play(); } } foreach (KeyValuePair <string, ICue> playingCue in playingCues) { string cue2 = playingCue.Key; if (!activeCues.Contains(cue2)) { cuesToStop.Add(cue2); } } foreach (string cue in cuesToStop) { playingCues[cue].Stop(AudioStopOptions.AsAuthored); playingCues.Remove(cue); } cuesToStop.Clear(); }
/// <summary> /// Uses a slightly edited version of the growth call of StardewValley.TerrainFeatures.Tree.dayUpdate. /// </summary> /// <param name="tree">current tree</param> /// <param name="location">ingame location (e.g. farm)</param> /// <param name="tileLocation">position in said location</param> /// <returns>whether the tree's growth is blocked by a stage 5 tree, depending on config even a stump is enough</returns> private bool IsGrowthBlocked(Tree tree, GameLocation location, Vector2 tileLocation) { Rectangle growthRect = new Rectangle((int)((tileLocation.X - 1f) * 64f), (int)((tileLocation.Y - 1f) * 64f), 192, 192); using (NetDictionary <Vector2, TerrainFeature, NetRef <TerrainFeature>, SerializableDictionary <Vector2, TerrainFeature>, NetVector2Dictionary <TerrainFeature, NetRef <TerrainFeature> > > .PairsCollection.Enumerator enumerator = location.terrainFeatures.Pairs.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <Vector2, TerrainFeature> t = enumerator.Current; if (t.Value is Tree && !t.Value.Equals(tree) && ((Tree)t.Value).growthStage >= 5 && (!((Tree)t.Value).stump || !config.GrowthIgnoresStumps) && t.Value.getBoundingBox(t.Key).Intersects(growthRect)) { return(true); } } return(false); } }
private List <FarmAnimal> GetAnimals(object currentLocation) { List <FarmAnimal> list = null; if (currentLocation is Farm farm) { if (farm.animals == null || farm.animals.Count() <= 0) { return(list); } list = new List <FarmAnimal>(); using (NetDictionary <long, FarmAnimal, NetRef <FarmAnimal>, SerializableDictionary <long, FarmAnimal>, NetLongDictionary <FarmAnimal, NetRef <FarmAnimal> > > .ValuesCollection.Enumerator enumerator = farm.animals.Values.GetEnumerator()) { while (enumerator.MoveNext()) { FarmAnimal item = enumerator.Current; list.Add(item); } return(list); } } if (currentLocation is AnimalHouse animalHouse) { if (animalHouse.animals != null && animalHouse.animals.Count() > 0) { list = new List <FarmAnimal>(); foreach (FarmAnimal item2 in animalHouse.animals.Values) { list.Add(item2); } } } return(list); }
/// <summary>Get a watcher for a net dictionary.</summary> /// <typeparam name="TKey">The dictionary key type.</typeparam> /// <typeparam name="TValue">The dictionary value type.</typeparam> /// <typeparam name="TField">The net type equivalent to <typeparamref name="TValue"/>.</typeparam> /// <typeparam name="TSerialDict">The serializable dictionary type that can store the keys and values.</typeparam> /// <typeparam name="TSelf">The net field instance type.</typeparam> /// <param name="field">The net field.</param> public static NetDictionaryWatcher <TKey, TValue, TField, TSerialDict, TSelf> ForNetDictionary <TKey, TValue, TField, TSerialDict, TSelf>(NetDictionary <TKey, TValue, TField, TSerialDict, TSelf> field) where TField : class, INetObject <INetSerializable>, new() where TSerialDict : IDictionary <TKey, TValue>, new() where TSelf : NetDictionary <TKey, TValue, TField, TSerialDict, TSelf> { return(new NetDictionaryWatcher <TKey, TValue, TField, TSerialDict, TSelf>(field)); }
public override void updateEvenIfFarmerIsntHere(GameTime time, bool skipWasUpdatedFlush = false) { base.updateEvenIfFarmerIsntHere(time, skipWasUpdatedFlush); if (Game1.currentLocation.Equals(( GameLocation )this)) { return; } NetDictionary <long, FarmAnimal, NetRef <FarmAnimal>, SerializableDictionary <long, FarmAnimal>, NetLongDictionary <FarmAnimal, NetRef <FarmAnimal> > > .PairsCollection pairs = this.Animals.Pairs; for (int index = pairs.Count() - 1; index >= 0; --index) { pairs.ElementAt(index).Value.updateWhenNotCurrentLocation(( Building )null, time, ( GameLocation )this); } }