public static void doMyPlayerUpdates(byte id) { MovingStatePacket currMoving = new MovingStatePacket(id, Game1.player); if (prevMoving == null || prevMoving.flags != currMoving.flags) { sendFunc(currMoving); } prevMoving = currMoving; int currSingleAnim = (int)Util.GetInstanceField(typeof(FarmerSprite), Game1.player.FarmerSprite, "currentSingleAnimation"); if (prevAnim != currSingleAnim || prevInterval != Game1.player.FarmerSprite.currentSingleAnimationInterval) { AnimationPacket anim = new AnimationPacket(id, Game1.player); if (anim.anim != -1 && anim.anim != FarmerSprite.walkLeft && anim.anim != FarmerSprite.walkDown && anim.anim != FarmerSprite.walkRight && anim.anim != FarmerSprite.walkUp && anim.anim != FarmerSprite.runLeft && anim.anim != FarmerSprite.runDown && anim.anim != FarmerSprite.runRight && anim.anim != FarmerSprite.runUp && anim.anim != FarmerSprite.carryWalkLeft && anim.anim != FarmerSprite.carryWalkDown && anim.anim != FarmerSprite.carryWalkRight && anim.anim != FarmerSprite.carryWalkUp && anim.anim != FarmerSprite.carryRunLeft && anim.anim != FarmerSprite.carryRunDown && anim.anim != FarmerSprite.carryRunRight && anim.anim != FarmerSprite.carryRunUp && anim.anim != FarmerSprite.showHoldingEdible /*&& anim.anim != FarmerSprite.eat*/) { sendFunc(anim); } } prevAnim = currSingleAnim; prevInterval = Game1.player.FarmerSprite.currentSingleAnimationInterval; if (prevActive != Game1.player.ActiveObject || prevTool != Game1.player.CurrentToolIndex) { HeldItemPacket held = new HeldItemPacket(id, Game1.player); sendFunc(held); } prevActive = Game1.player.ActiveObject; prevTool = Game1.player.CurrentToolIndex; CoopUpdatePacket currCoopState = new CoopUpdatePacket(); if (prevCoopState == null) { prevCoopState = currCoopState; } if (!prevCoopState.Equals(currCoopState)) { sendFunc(currCoopState); } prevCoopState = currCoopState; if (Game1.player.dancePartner != null && !hadDancePartner) { sendFunc(new FestivalDancePartnerPacket(( byte )(mode == Mode.Host ? 0 : client.id), Game1.player.dancePartner.name)); hadDancePartner = true; } if (Game1.player.spouse != prevSpouse) { sendFunc(new SpousePacket((byte)(mode == Mode.Host ? 0 : client.id), prevSpouse)); } prevSpouse = Game1.player.spouse; }
public static void locationChange(GameLocation oldLoc, GameLocation newLoc) { string newLocName = getUniqueLocationName(newLoc); Log.Async("(Me) " + SaveGame.loaded.player.name + " moved to " + newLocName + " (" + newLoc + ")"); LocationPacket loc = new LocationPacket(getMyId(), newLocName); MovingStatePacket move = new MovingStatePacket(getMyId(), Game1.player); if (!goingToFestival) { Multiplayer.sendFunc(loc); } Multiplayer.sendFunc(move); if (Multiplayer.mode == Mode.Host && server.playing) { // Move everyone to the festival if (newLocName == "Temp" && Game1.player.currentLocation.currentEvent != null) { foreach (Server.Client other in server.clients) { if (other.farmer.currentLocation != null) { other.farmer.currentLocation.farmers.Remove(other.farmer); } other.farmer.currentLocation = Game1.player.currentLocation; other.farmer.currentLocation.farmers.Add(other.farmer); } goingToFestival = false; } else if (oldLoc.Name == "Temp") { foreach (Server.Client other in server.clients) { if (other.farmer.currentLocation != oldLoc) { continue; } other.farmer.currentLocation.farmers.Remove(other.farmer); other.farmer.currentLocation = Game1.player.currentLocation; other.farmer.currentLocation.farmers.Add(other.farmer); } } } else if (Multiplayer.mode == Mode.Client && client.stage == Client.NetStage.Playing) { if (newLocName == "Temp" && Game1.player.currentLocation.currentEvent != null) { foreach (KeyValuePair <byte, Farmer> other in client.others) { if (other.Value.currentLocation != null) { other.Value.currentLocation.farmers.Remove(other.Value); } other.Value.currentLocation = Game1.player.currentLocation; other.Value.currentLocation.farmers.Add(other.Value); } goingToFestival = false; } else if (oldLoc.Name == "Temp") { foreach (KeyValuePair <byte, Farmer> other in client.others) { if (other.Value.currentLocation != oldLoc) { continue; } other.Value.currentLocation.farmers.Remove(other.Value); other.Value.currentLocation = Game1.player.currentLocation; other.Value.currentLocation.farmers.Add(other.Value); } } } }