Ejemplo n.º 1
0
        public static void serverTryToPerformObjectAlteration(short x, short y, byte command, byte terrainFeatureIndex, int extraInfo, Farmer actionPerformer)
        {
            switch (command)
            {
            case 0:
                extraInfo = MultiplayerUtility.translateObjectIndex(extraInfo);
                Object object1 = (int)terrainFeatureIndex != 0 ? new Object(Vector2.Zero, extraInfo, false) : new Object(Vector2.Zero, extraInfo, (string)null, true, false, false, false);
                if (!Utility.playerCanPlaceItemHere(actionPerformer.currentLocation, (Item)object1, (int)x, (int)y, actionPerformer))
                {
                    break;
                }
                object1.placementAction(Game1.currentLocation, (int)x, (int)y, (Farmer)null);
                break;

            case 1:
                Object object2 = Game1.currentLocation.objects[new Vector2((float)x, (float)y)];
                Game1.currentLocation.objects.Remove(new Vector2((float)x, (float)y));
                if (object2 == null)
                {
                    break;
                }
                object2.performRemoveAction(new Vector2((float)x, (float)y), Game1.currentLocation);
                break;

            case 2:
                Game1.currentLocation.terrainFeatures.Add(new Vector2((float)x, (float)y), TerrainFeatureFactory.getNewTerrainFeatureFromIndex(terrainFeatureIndex, extraInfo));
                break;

            case 3:
                Game1.currentLocation.terrainFeatures.Remove(new Vector2((float)x, (float)y));
                break;
            }
        }
Ejemplo n.º 2
0
        public static void performObjectAlteration(short x, short y, byte command, byte terrainFeatureIndex, int extraInfo)
        {
            switch (command)
            {
            case 0:
                extraInfo = MultiplayerUtility.translateObjectIndex(extraInfo);
                ((int)terrainFeatureIndex != 0 ? new Object(Vector2.Zero, extraInfo, false) : new Object(Vector2.Zero, extraInfo, (string)null, true, false, false, false)).placementAction(Game1.currentLocation, (int)x * Game1.tileSize, (int)y * Game1.tileSize, (Farmer)null);
                break;

            case 1:
                Object @object;
                Game1.currentLocation.objects.TryGetValue(new Vector2((float)x, (float)y), out @object);
                if (@object == null)
                {
                    break;
                }
                Game1.currentLocation.objects.Remove(new Vector2((float)x, (float)y));
                @object.performRemoveAction(new Vector2((float)x, (float)y), Game1.currentLocation);
                break;

            case 2:
                if (Game1.currentLocation.terrainFeatures.ContainsKey(new Vector2((float)x, (float)y)))
                {
                    Game1.currentLocation.terrainFeatures[new Vector2((float)x, (float)y)] = TerrainFeatureFactory.getNewTerrainFeatureFromIndex(terrainFeatureIndex, extraInfo);
                    break;
                }
                Game1.currentLocation.terrainFeatures.Add(new Vector2((float)x, (float)y), TerrainFeatureFactory.getNewTerrainFeatureFromIndex(terrainFeatureIndex, extraInfo));
                break;

            case 3:
                Game1.currentLocation.terrainFeatures.Remove(new Vector2((float)x, (float)y));
                break;
            }
        }
Ejemplo n.º 3
0
        public static void performObjectAlteration(short x, short y, byte command, byte terrainFeatureIndex, int extraInfo)
        {
            switch (command)
            {
            case 0:
            {
                extraInfo = MultiplayerUtility.translateObjectIndex(extraInfo);
                Object @object;
                if (terrainFeatureIndex == 0)
                {
                    @object = new Object(Vector2.Zero, extraInfo, null, true, false, false, false);
                }
                else
                {
                    @object = new Object(Vector2.Zero, extraInfo, false);
                }
                @object.placementAction(Game1.currentLocation, (int)x * Game1.tileSize, (int)y * Game1.tileSize, null);
                return;
            }

            case 1:
            {
                Object @object;
                Game1.currentLocation.objects.TryGetValue(new Vector2((float)x, (float)y), out @object);
                if (@object != null)
                {
                    Game1.currentLocation.objects.Remove(new Vector2((float)x, (float)y));
                    @object.performRemoveAction(new Vector2((float)x, (float)y), Game1.currentLocation);
                    return;
                }
                break;
            }

            case 2:
                if (Game1.currentLocation.terrainFeatures.ContainsKey(new Vector2((float)x, (float)y)))
                {
                    Game1.currentLocation.terrainFeatures[new Vector2((float)x, (float)y)] = TerrainFeatureFactory.getNewTerrainFeatureFromIndex(terrainFeatureIndex, extraInfo);
                    return;
                }
                Game1.currentLocation.terrainFeatures.Add(new Vector2((float)x, (float)y), TerrainFeatureFactory.getNewTerrainFeatureFromIndex(terrainFeatureIndex, extraInfo));
                return;

            case 3:
                Game1.currentLocation.terrainFeatures.Remove(new Vector2((float)x, (float)y));
                break;

            default:
                return;
            }
        }
Ejemplo n.º 4
0
        public static void serverTryToPerformObjectAlteration(short x, short y, byte command, byte terrainFeatureIndex, int extraInfo, Farmer actionPerformer)
        {
            switch (command)
            {
            case 0:
            {
                extraInfo = MultiplayerUtility.translateObjectIndex(extraInfo);
                Object @object;
                if (terrainFeatureIndex == 0)
                {
                    @object = new Object(Vector2.Zero, extraInfo, null, true, false, false, false);
                }
                else
                {
                    @object = new Object(Vector2.Zero, extraInfo, false);
                }
                if (Utility.playerCanPlaceItemHere(actionPerformer.currentLocation, @object, (int)x, (int)y, actionPerformer))
                {
                    @object.placementAction(Game1.currentLocation, (int)x, (int)y, null);
                    return;
                }
                break;
            }

            case 1:
            {
                Object @object = Game1.currentLocation.objects[new Vector2((float)x, (float)y)];
                Game1.currentLocation.objects.Remove(new Vector2((float)x, (float)y));
                if (@object != null)
                {
                    @object.performRemoveAction(new Vector2((float)x, (float)y), Game1.currentLocation);
                    return;
                }
                break;
            }

            case 2:
                Game1.currentLocation.terrainFeatures.Add(new Vector2((float)x, (float)y), TerrainFeatureFactory.getNewTerrainFeatureFromIndex(terrainFeatureIndex, extraInfo));
                return;

            case 3:
                Game1.currentLocation.terrainFeatures.Remove(new Vector2((float)x, (float)y));
                break;

            default:
                return;
            }
        }