public bool Process(ServerClient client) { if (client.State != ClientState.Playing) { return(false); } Player player = MapLogic.Instance.GetNetPlayer(client); if (player == null) { return(false); } MapUnit unit = MapLogic.Instance.GetUnitByTag(UnitTag); if (unit == null || unit.Player != player) { return(true); } MapStructure structure = MapLogic.Instance.GetStructureByTag(StructureTag); if (structure == null || structure.Class == null || !structure.Class.Usable) { return(false); } unit.SetState(new UseStructureState(unit, structure)); return(true); }
public ShopStructure(MapStructure s, AllodsMap.AlmShop rules) : base(s) { for (int i = 0; i < 4; i++) { Shelves[i] = new Shelf(rules.Shelves[i]); Debug.LogFormat("Generated Shelf [{1}] in shop ID={2}:\n{0}", Shelves[i].Items.ToString(), i + 1, s.Tag); } }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
public static void SendUseStructure(MapUnit unit, MapStructure s) { if (NetworkManager.IsClient) { ServerCommands.UseStructure useStructureCmd; useStructureCmd.UnitTag = unit.Tag; useStructureCmd.StructureTag = s.Tag; ClientManager.SendCommand(useStructureCmd); } else { if (MapLogic.Instance.ConsolePlayer == unit.Player) { unit.SetState(new UseStructureState(unit, s)); } } }
public MapStructure GetStructureByTag(int tag) { foreach (MapObject mobj in Objects) { if (mobj.GetObjectType() != MapObjectType.Structure) { continue; } MapStructure struc = (MapStructure)mobj; if (struc.Tag == tag) { return(struc); } } return(null); }
public static void NotifyEnterShop(MapUnit unit, MapStructure shop) { if (NetworkManager.IsServer) { Player p = unit.Player; if (p != null && p.NetClient != null && p.NetClient.State == ClientState.Playing) { ClientCommands.EnterShop enterShopCmd; enterShopCmd.Tag = shop.Tag; p.NetClient.SendCommand(enterShopCmd); } } else if (!NetworkManager.IsClient) { // process locally ClientCommands.EnterShop enterShopCmd; enterShopCmd.Tag = shop.Tag; enterShopCmd.Process(); } }
public bool Process() { if (!MapLogic.Instance.IsLoaded) { return(false); } MapStructure s = MapLogic.Instance.GetStructureByTag(Tag); if (s == null || s.Class == null || !s.Class.Usable) { Debug.LogFormat("Attempted to enter nonexistent building {0}", Tag); return(false); } InnScreen screen = Utils.CreateObjectWithScript <InnScreen>(); screen.Inn = s; return(true); }
public MazeGenerator(ref MapStructure map) { this.map = map; }
public InnStructure(MapStructure s, AllodsMap.AlmInnInfo info) : base(s) { Rules = info; }
protected StructureLogic(MapStructure s) { Structure = s; }
public void InitFromFile(string filename) { Unload(); InitGeneric(); AllodsMap mapStructure = AllodsMap.LoadFrom(filename); if (mapStructure == null) { //Core.Abort("Couldn't load \"{0}\"", filename); GameConsole.Instance.WriteLine("Couldn't load \"{0}\"", filename); Unload(); return; } Width = (int)mapStructure.Data.Width; Height = (int)mapStructure.Data.Height; Nodes = new MapNode[Width, Height]; for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { Nodes[x, y] = new MapNode(); Nodes[x, y].Tile = (ushort)(mapStructure.Tiles[y * Width + x] & 0x3FF); Nodes[x, y].Height = mapStructure.Heights[y * Width + x]; Nodes[x, y].Flags = 0; Nodes[x, y].Light = 255; } } // load players foreach (AllodsMap.AlmPlayer almplayer in mapStructure.Players) { Player player = new Player(almplayer); Players.Add(player); //Debug.Log(string.Format("player ID={2} {0} (flags {1})", player.Name, player.Flags, player.ID)); } GameManager.Instance.CallDelegateOnNextFrame(() => { Speed = 5; return(false); }); _TopObjectID = 0; // load obstacles for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { int typeId = mapStructure.Objects[y * Width + x]; if (typeId <= 0) { continue; } typeId -= 1; MapObstacle mob = new MapObstacle(typeId); mob.X = x; mob.Y = y; mob.LinkToWorld(); Objects.Add(mob); } } // load structures if (mapStructure.Structures != null) { foreach (AllodsMap.AlmStructure almstruc in mapStructure.Structures) { MapStructure struc; struc = new MapStructure(almstruc.TypeID); struc.X = (int)almstruc.X; struc.Y = (int)almstruc.Y; struc.Health = almstruc.Health; struc.Tag = almstruc.ID; struc.Player = GetPlayerByID(almstruc.Player - 1); if (almstruc.IsBridge) { struc.Width = almstruc.Width; struc.Height = almstruc.Height; // also this crutch is apparently done by ROM2 if (struc.Width < 2) { struc.Width = 2; } if (struc.Height < 2) { struc.Height = 2; } struc.IsBridge = true; } struc.LinkToWorld(); Objects.Add(struc); } } // load units if (!NetworkManager.IsClient && mapStructure.Units != null) { foreach (AllodsMap.AlmUnit almunit in mapStructure.Units) { if ((almunit.Flags & 0x10) != 0) { MapHuman human = new MapHuman(almunit.ServerID); human.X = (int)almunit.X; human.Y = (int)almunit.Y; human.Tag = almunit.ID; human.Player = GetPlayerByID(almunit.Player - 1); if (almunit.HealthMax >= 0) { human.Stats.HealthMax = almunit.HealthMax; } if (almunit.Health >= 0) { human.Stats.TrySetHealth(almunit.Health); } human.LinkToWorld(); Objects.Add(human); } else { MapUnit unit = new MapUnit(almunit.ServerID); unit.X = (int)almunit.X; unit.Y = (int)almunit.Y; unit.Tag = almunit.ID; unit.Player = GetPlayerByID(almunit.Player - 1); if (almunit.HealthMax >= 0) { unit.Stats.HealthMax = almunit.HealthMax; } if (almunit.Health >= 0) { unit.Stats.TrySetHealth(almunit.Health); } unit.LinkToWorld(); Objects.Add(unit); } } } // only if loaded MapStructure = mapStructure; FileName = filename; FileMD5 = ResourceManager.CalcMD5(FileName); MapLighting = new TerrainLighting(Width, Height); CalculateLighting(180); // postprocessing // if we are playing in singleplayer, then console player is Self. if (!NetworkManager.IsClient && !NetworkManager.IsServer) { Player Self = GetPlayerByName("Self"); if (Self == null) { GameConsole.Instance.WriteLine("Error: couldn't set ConsolePlayer: Self not found!"); } else { ConsolePlayer = Self; } if (ConsolePlayer != null) { ConsolePlayer.Flags = 0; ConsolePlayer.Diplomacy[ConsolePlayer.ID] = DiplomacyFlags.Ally | DiplomacyFlags.Vision; GameManager.Instance.CallDelegateOnNextFrame(() => { ConsolePlayer.Avatar = CreateAvatar(ConsolePlayer); // center view on avatar. MapView.Instance.CenterOnObject(ConsolePlayer.Avatar); return(false); }); } } if (!NetworkManager.IsClient) { // testing /* * ItemPack testpack = new ItemPack(); * testpack.PutItem(0, new Item("Very Rare Crystal Ring")); * PutSackAt(16, 16, testpack, false); */ /* * MapProjectile proj = new MapProjectile(15); * proj.SetPosition(16, 16, 0); * Objects.Add(proj); */ } }
public UseStructureState(MapUnit unit, MapStructure s) { Unit = unit; Structure = s; Walker = new UnitStateWalker(); }
private void InitFromFileWorker(string filename) { try { AllodsMap mapStructure = AllodsMap.LoadFrom(filename); if (mapStructure == null) { //Core.Abort("Couldn't load \"{0}\"", filename); GameConsole.Instance.WriteLine("Couldn't load \"{0}\"", filename); Unload(); return; } Width = (int)mapStructure.Data.Width; Height = (int)mapStructure.Data.Height; Nodes = new MapNode[Width, Height]; for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { Nodes[x, y] = new MapNode(); Nodes[x, y].Tile = (ushort)(mapStructure.Tiles[y * Width + x] & 0x3FF); Nodes[x, y].Height = mapStructure.Heights[y * Width + x]; Nodes[x, y].Flags = 0; Nodes[x, y].Light = 255; } } // load players foreach (AllodsMap.AlmPlayer almplayer in mapStructure.Players) { Player player = new Player(almplayer); Players.Add(player); //Debug.Log(string.Format("player ID={2} {0} (flags {1})", player.Name, player.Flags, player.ID)); } GameManager.Instance.CallDelegateOnNextFrame(() => { Speed = 5; return(false); }); _TopObjectID = 0; // load obstacles for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { int typeId = mapStructure.Objects[y * Width + x]; if (typeId <= 0) { continue; } typeId -= 1; MapObstacle mob = new MapObstacle(typeId); mob.X = x; mob.Y = y; mob.LinkToWorld(); Objects.Add(mob); } } // load structures if (mapStructure.Structures != null) { foreach (AllodsMap.AlmStructure almstruc in mapStructure.Structures) { MapStructure struc; struc = new MapStructure(almstruc.TypeID); struc.X = (int)almstruc.X; struc.Y = (int)almstruc.Y; struc.Health = almstruc.Health; struc.Tag = almstruc.ID; struc.Player = GetPlayerByID(almstruc.Player - 1); if (almstruc.IsBridge) { struc.Width = almstruc.Width; struc.Height = almstruc.Height; // also this crutch is apparently done by ROM2 if (struc.Width < 2) { struc.Width = 2; } if (struc.Height < 2) { struc.Height = 2; } struc.IsBridge = true; } struc.LinkToWorld(); Objects.Add(struc); } } // load groups if (!NetworkManager.IsClient && mapStructure.Groups != null) { foreach (AllodsMap.AlmGroup almgroup in mapStructure.Groups) { Group grp = FindNewGroup((int)almgroup.GroupID); grp.RepopDelay = (int)almgroup.RepopTime * TICRATE; grp.Flags = 0; if (almgroup.GroupFlag.HasFlag(AllodsMap.AlmGroup.AlmGroupFlags.RandomPositions)) { grp.Flags |= GroupFlags.RandomPositions; } if (almgroup.GroupFlag.HasFlag(AllodsMap.AlmGroup.AlmGroupFlags.QuestKill)) { grp.Flags |= GroupFlags.QuestKill; } if (almgroup.GroupFlag.HasFlag(AllodsMap.AlmGroup.AlmGroupFlags.QuestIntercept)) { grp.Flags |= GroupFlags.QuestIntercept; } } } // load units if (!NetworkManager.IsClient && mapStructure.Units != null) { int c = 0; System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); foreach (AllodsMap.AlmUnit almunit in mapStructure.Units) { if ((almunit.Flags & 0x10) != 0) { MapHuman human = new MapHuman(almunit.ServerID); human.X = human.TargetX = human.SpawnX = human.LastSpawnX = (int)almunit.X; human.Y = human.TargetY = human.SpawnY = human.LastSpawnY = (int)almunit.Y; human.Tag = almunit.ID; human.Player = GetPlayerByID(almunit.Player - 1); if (almunit.HealthMax >= 0) { human.CoreStats.HealthMax = almunit.HealthMax; human.UpdateItems(); } if (almunit.Health >= 0) { human.Stats.TrySetHealth(almunit.Health); } human.CalculateVision(); human.Group = FindNewGroup(almunit.Group); human.LinkToWorld(); Objects.Add(human); } else { MapUnit unit = new MapUnit(almunit.ServerID); unit.X = unit.TargetX = unit.SpawnX = unit.LastSpawnX = (int)almunit.X; unit.Y = unit.TargetY = unit.SpawnY = unit.LastSpawnY = (int)almunit.Y; unit.Tag = almunit.ID; unit.Player = GetPlayerByID(almunit.Player - 1); if (almunit.HealthMax >= 0) { unit.CoreStats.HealthMax = almunit.HealthMax; unit.UpdateItems(); } if (almunit.Health >= 0) { unit.Stats.TrySetHealth(almunit.Health); } unit.CalculateVision(); unit.Group = FindNewGroup(almunit.Group); unit.LinkToWorld(); Objects.Add(unit); } } } // only if loaded MapStructure = mapStructure; FileName = filename; FileMD5 = ResourceManager.CalcMD5(FileName); MapLighting = new TerrainLighting(Width, Height); CalculateLighting(180); // postprocessing // if we are playing in singleplayer, then console player is Self. if (!NetworkManager.IsClient && !NetworkManager.IsServer) { Player Self = GetPlayerByName("Self"); if (Self == null) { GameConsole.Instance.WriteLine("Error: couldn't set ConsolePlayer: Self not found!"); } else { ConsolePlayer = Self; } if (ConsolePlayer != null) { ConsolePlayer.Name = Config.cl_nickname.Length == 0 ? "Self" : Config.cl_nickname; ConsolePlayer.Flags = 0; ConsolePlayer.Diplomacy[ConsolePlayer.ID] = DiplomacyFlags.Ally | DiplomacyFlags.Vision; GameManager.Instance.CallDelegateOnNextFrame(() => { ConsolePlayer.Avatar = CreateAvatar(ConsolePlayer); // center view on avatar. MapView.Instance.CenterOnObject(ConsolePlayer.Avatar); return(false); }); } } if (!NetworkManager.IsClient) { // testing /* * ItemPack testpack = new ItemPack(); * testpack.PutItem(0, new Item("Very Rare Crystal Ring")); * PutSackAt(16, 16, testpack, false); */ /* * MapProjectile proj = new MapProjectile(15); * proj.SetPosition(16, 16, 0); * Objects.Add(proj); */ } /* WarBeginner */ Wizard.LoadMap(this); GameManager.Instance.CallDelegateOnNextFrame(() => { MapView.Instance.OnMapLoaded(); return(false); }); } catch (Exception e) { Debug.LogError(e); GameConsole.Instance.WriteLine("Failed to load {0}: {1}: {2}", filename, e.GetType().Name, e.Message); MapStructure = null; } finally { IsLoading = false; } }
private void InitFromFileWorker(string filename) { try { PathfindingType = (PathfindingType)Config.sv_pathfinding; AllodsMap mapStructure = AllodsMap.LoadFrom(filename); if (mapStructure == null) { //Core.Abort("Couldn't load \"{0}\"", filename); GameConsole.Instance.WriteLine("Couldn't load \"{0}\"", filename); Unload(); return; } Width = (int)mapStructure.Data.Width; Height = (int)mapStructure.Data.Height; // load in map.reg // for base terrain costs here Registry reg = null; try { reg = new Registry("world/data/map.reg"); } catch (Exception) { reg = new Registry(); } int[] NodeCosts = new int[] { reg.GetInt("Terrain", "CostLand", 8), reg.GetInt("Terrain", "CostGrass", 8), reg.GetInt("Terrain", "CostFlowers", 9), reg.GetInt("Terrain", "CostSand", 14), reg.GetInt("Terrain", "CostCracked", 6), reg.GetInt("Terrain", "CostStones", 12), reg.GetInt("Terrain", "CostSavanna", 11), reg.GetInt("Terrain", "CostMountain", 16), reg.GetInt("Terrain", "CostWater", 8), reg.GetInt("Terrain", "CostRoad", 6) }; int[] NodeTileTypesInCell = new int[] { 2, 3, 2, 4, 3, 4, 2, 2, 2, 2, 4, 4, 4, 4, 0, 0, 3, 5, 3, 3, 1, 3, 2, 4, 2, 2, 4, 2, 4, 4, 0, 0, 2, 3, 2, 4, 3, 4, 2, 4, 2, 2, 4, 2, 4, 4, 0, 0, 5, 5, 5, 5, 5, 5, 2, 2, 2, 2, 4, 4, 4, 4, 0, 0 }; int[,] NodeTileTypes = new int[16, 2] { { 2, 1 }, { 5, 1 }, { 4, 1 }, { 7, 1 }, { 6, 1 }, { 5, 6 }, { 3, 7 }, { 8, 6 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 10, 1 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; // end loading terrain costs Nodes = new MapNode[Width, Height]; for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { MapNode node = Nodes[x, y] = new MapNode(); node.Tile = (ushort)(mapStructure.Tiles[y * Width + x] & 0x3FF); node.Height = mapStructure.Heights[y * Width + x]; node.Flags = 0; node.Light = 255; int costTileType = (node.Tile & 0x3C0) >> 6; int costTileBorder = (node.Tile & 0x3F); float costTileFactor = (NodeTileTypesInCell[costTileBorder] - 1) / 4f; // 1..5 -> 0..4 -> 0..1 int costSubTileType1 = NodeTileTypes[costTileType, 1] - 1; int costSubTileType2 = NodeTileTypes[costTileType, 0] - 1; int costSubTile1 = (costSubTileType1 >= 0) ? NodeCosts[costSubTileType1] : 0; int costSubTile2 = (costSubTileType2 >= 0) ? NodeCosts[costSubTileType2] : 0; node.BaseWalkCost = (byte)((costSubTile1 * (1f - costTileFactor)) + (costSubTile2 * costTileFactor)); // 7 = rock // 8 = water int walkType = costSubTileType1; float walkFactor = 1f - costTileFactor; if (costSubTileType2 == 7 || costSubTileType2 == 8 || costSubTileType1 == -1) { walkType = costSubTileType2; walkFactor = costTileFactor; } if (walkType < 0 || walkType == 8 || (walkType == 7 && walkFactor > 0.25f)) { node.Flags |= MapNodeFlags.BlockedTerrain; } } } // load players foreach (AllodsMap.AlmPlayer almplayer in mapStructure.Players) { Player player = new Player(almplayer); Players.Add(player); //Debug.Log(string.Format("player ID={2} {0} (flags {1})", player.Name, player.Flags, player.ID)); } GameManager.Instance.CallDelegateOnNextFrame(() => { Speed = 5; return(false); }); _TopObjectID = 0; // load obstacles for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { int typeId = mapStructure.Objects[y * Width + x]; if (typeId <= 0) { continue; } typeId -= 1; MapObstacle mob = new MapObstacle(typeId); mob.X = x; mob.Y = y; mob.LinkToWorld(); AddObject(mob, false); } } // load structures if (mapStructure.Structures != null) { foreach (AllodsMap.AlmStructure almstruc in mapStructure.Structures) { MapStructure struc; struc = new MapStructure(almstruc.TypeID); if (struc.Class == null) { Debug.LogFormat("Tried to load invalid structure {0}", almstruc.TypeID); continue; } struc.X = (int)almstruc.X; struc.Y = (int)almstruc.Y; struc.Health = almstruc.Health; struc.Tag = almstruc.ID; struc.Player = GetPlayerByID(almstruc.Player - 1); if (almstruc.IsBridge) { struc.Width = almstruc.Width; struc.Height = almstruc.Height; // also this crutch is apparently done by ROM2 if (struc.Width < 2) { struc.Width = 2; } if (struc.Height < 2) { struc.Height = 2; } struc.IsBridge = true; } // find inn/shop data if needed if (struc.Class != null && struc.Class.Usable) { if ((struc.Class.ID >= 105 && struc.Class.ID <= 107) || // druid shop (struc.Class.ID >= 34 && struc.Class.ID <= 35) || // plagat shop (struc.Class.ID >= 93 && struc.Class.ID <= 95)) // kaarg shop { foreach (AllodsMap.AlmShop shop in mapStructure.Shops) { if (shop.ID == struc.Tag) { struc.Logic = new ShopStructure(struc, shop); break; } } if (struc.Logic == null) { Debug.LogFormat("Warning: Loaded multiplayer shop without data (ID={0})", struc.ID); } } else if ((struc.Class.ID >= 99 && struc.Class.ID <= 101) || // kaarg inn (struc.Class.ID >= 111 && struc.Class.ID <= 113) || // druid inn (struc.Class.ID >= 67 && struc.Class.ID <= 69)) // plagat inn { foreach (AllodsMap.AlmInnInfo info in mapStructure.Inns) { if (info.ID == struc.Tag) { struc.Logic = new InnStructure(struc, info); break; } } if (struc.Logic == null) { Debug.LogFormat("Warning: Loaded multiplayer inn without data (ID={0})", struc.ID); } } } struc.LinkToWorld(); AddObject(struc, (struc.Logic != null)); } } // load groups if (!NetworkManager.IsClient && mapStructure.Groups != null) { foreach (AllodsMap.AlmGroup almgroup in mapStructure.Groups) { Group grp = FindNewGroup((int)almgroup.GroupID); grp.RepopDelay = (int)almgroup.RepopTime * TICRATE; grp.Flags = 0; if (almgroup.GroupFlag.HasFlag(AllodsMap.AlmGroup.AlmGroupFlags.RandomPositions)) { grp.Flags |= GroupFlags.RandomPositions; } if (almgroup.GroupFlag.HasFlag(AllodsMap.AlmGroup.AlmGroupFlags.QuestKill)) { grp.Flags |= GroupFlags.QuestKill; } if (almgroup.GroupFlag.HasFlag(AllodsMap.AlmGroup.AlmGroupFlags.QuestIntercept)) { grp.Flags |= GroupFlags.QuestIntercept; } } } // load units if (!NetworkManager.IsClient && mapStructure.Units != null) { System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); foreach (AllodsMap.AlmUnit almunit in mapStructure.Units) { if ((almunit.Flags & 0x10) != 0) { MapHuman human = new MapHuman(almunit.ServerID); if (human.Class == null) { Debug.LogFormat("Tried to load invalid unit {0}", almunit.ServerID); continue; } human.X = human.TargetX = human.SpawnX = human.LastSpawnX = (int)almunit.X; human.Y = human.TargetY = human.SpawnY = human.LastSpawnY = (int)almunit.Y; human.Tag = almunit.ID; human.Player = GetPlayerByID(almunit.Player - 1); if (almunit.HealthMax >= 0) { human.CoreStats.HealthMax = almunit.HealthMax; human.UpdateItems(); } if (almunit.Health >= 0) { human.Stats.TrySetHealth(almunit.Health); } human.CalculateVision(); human.Group = FindNewGroup(almunit.Group); human.LinkToWorld(); AddObject(human, true); } else { MapUnit unit = new MapUnit(almunit.ServerID); if (unit.Class == null) { Debug.LogFormat("Tried to load invalid unit {0}", almunit.ServerID); continue; } unit.X = unit.TargetX = unit.SpawnX = unit.LastSpawnX = (int)almunit.X; unit.Y = unit.TargetY = unit.SpawnY = unit.LastSpawnY = (int)almunit.Y; unit.Tag = almunit.ID; unit.Player = GetPlayerByID(almunit.Player - 1); if (almunit.HealthMax >= 0) { unit.CoreStats.HealthMax = almunit.HealthMax; unit.UpdateItems(); } if (almunit.Health >= 0) { unit.Stats.TrySetHealth(almunit.Health); } unit.CalculateVision(); unit.Group = FindNewGroup(almunit.Group); unit.LinkToWorld(); AddObject(unit, true); } } } // load items into units if (!NetworkManager.IsClient && mapStructure.Sacks != null) { foreach (AllodsMap.AlmSack almsack in mapStructure.Sacks) { if (almsack.Items.Length <= 0) { continue; } MapUnit unit = null; MapSack sack = null; if (almsack.UnitID != 0) { unit = GetUnitByTag((int)almsack.UnitID); if (unit == null) { Debug.LogFormat("Error: Can't resolve unit ID {0} for sack", almsack.UnitID); continue; } } else { sack = PutSackAt((int)almsack.X, (int)almsack.Y, new ItemPack(), false); sack.Pack.Money += almsack.Gold; } List <Item> items = new List <Item>(); foreach (AllodsMap.AlmSackItem almitem in almsack.Items) { List <ItemEffect> effects = new List <ItemEffect>(); AllodsMap.AlmEffect almBaseEffect = null; int almBaseEffectId = (int)(almitem.EffectNumber - 1); if (mapStructure.Effects != null && almBaseEffectId >= 0 && almBaseEffectId < mapStructure.Effects.Length) { almBaseEffect = mapStructure.Effects[almBaseEffectId]; foreach (AllodsMap.AlmEffectModifier mod in almBaseEffect.EffectModifiers) { ItemEffect effect = new ItemEffect((ItemEffect.Effects)mod.TypeOfMod, (int)mod.Value); effects.Add(effect); } } else if (almBaseEffectId >= 0) { Debug.LogFormat("Warning: Can't resolve effect #{0} for sack item", almBaseEffectId); } Item item = new Item((ushort)almitem.ItemID, effects); if (unit != null) { if (almitem.Wielded > 0) { unit.PutItemToBody((MapUnit.BodySlot)item.Class.Option.Slot, item); } else { unit.ItemsPack.PutItem(unit.ItemsPack.Count, item); } } else if (sack != null) { sack.Pack.PutItem(sack.Pack.Count, item); } } } } //* WB_pathfind if (PathfindingType == PathfindingType.Flood) { Wizard.LoadMap(this); } //* end // only if loaded MapStructure = mapStructure; FileName = filename; FileMD5 = ResourceManager.CalcMD5(FileName); MapLighting = new TerrainLighting(Width, Height); CalculateLighting(180); // postprocessing // if we are playing in singleplayer, then console player is Self. if (!NetworkManager.IsClient && !NetworkManager.IsServer) { Player Self = GetPlayerByName("Self"); if (Self == null) { GameConsole.Instance.WriteLine("Error: couldn't set ConsolePlayer: Self not found!"); } else { ConsolePlayer = Self; } if (ConsolePlayer != null) { ConsolePlayer.Name = Config.cl_nickname.Length == 0 ? "Self" : Config.cl_nickname; ConsolePlayer.Flags = 0; ConsolePlayer.Diplomacy[ConsolePlayer.ID] = DiplomacyFlags.Ally | DiplomacyFlags.Vision; GameManager.Instance.CallDelegateOnNextFrame(() => { ConsolePlayer.Avatar = CreateAvatar(ConsolePlayer); // center view on avatar. MapView.Instance.CenterOnObject(ConsolePlayer.Avatar); return(false); }); } } if (!NetworkManager.IsClient) { // testing /* * ItemPack testpack = new ItemPack(); * testpack.PutItem(0, new Item("Very Rare Crystal Ring")); * PutSackAt(16, 16, testpack, false); */ /* * MapProjectile proj = new MapProjectile(15); * proj.SetPosition(16, 16, 0); * Objects.Add(proj); */ } GameManager.Instance.CallDelegateOnNextFrame(() => { MapView.Instance.OnMapLoaded(); return(false); }); } catch (Exception e) { Debug.LogError(e); GameConsole.Instance.WriteLine("Failed to load {0}: {1}: {2}", filename, e.GetType().Name, e.Message); MapStructure = null; } finally { IsLoading = false; } }
public ShopStructure(MapStructure s, AllodsMap.AlmShop rules) : base(s) { Rules = rules; }
public RoomsGenerator(ref MapStructure map) { this.map = map; }
public void OnUpdate(UpdatePacket update) { GameObject[] lakUpSXZB1zdJcCECL20tl6SVrT = update._NewObjects; int num = 0; GameObject gameObject = default(GameObject); TileObject[] _2CIHnoEa49dfPXyqt9nkkBlUcQf = default(TileObject[]); MapStructure mapStructure = default(MapStructure); ObjectStructure objectStructure = default(ObjectStructure); Tile jDuaG31Xe8XJ3zd9YVFcuUiYrW = default(Tile); while (true) { int num2; int num3; if (num >= lakUpSXZB1zdJcCECL20tl6SVrT.Length) { num2 = 2010952782; num3 = num2; } else { num2 = 1620547635; num3 = num2; } while (true) { uint num4; switch ((num4 = (uint)num2 ^ 0x7E3FB22Du) % 24u) { case 12u: num2 = 1620547635; continue; default: return; case 13u: SetTileSafety((int)gameObject._Status._Position._PositionX, (int)gameObject._Status._Position._PositionY, value: true); num2 = ((int)num4 * -961744554) ^ -243430478; continue; case 16u: { int num9; if (num >= _2CIHnoEa49dfPXyqt9nkkBlUcQf.Length) { num2 = 1733640553; num9 = num2; } else { num2 = 333317702; num9 = num2; } continue; } case 17u: { int num16; if (mapStructure._Tile.MinDamage <= 0) { num2 = 261571655; num16 = num2; } else { num2 = 2001023909; num16 = num2; } continue; } case 6u: gameObject = lakUpSXZB1zdJcCECL20tl6SVrT[num]; num2 = 1685888117; continue; case 2u: break; case 19u: { int num20; int num21; if (objectStructure.ProtectFromGroundDamage) { num20 = 622838595; num21 = num20; } else { num20 = 2028001239; num21 = num20; } num2 = num20 ^ (int)(num4 * 444209681); continue; } case 7u: num++; num2 = 880993805; continue; case 22u: jDuaG31Xe8XJ3zd9YVFcuUiYrW._gNqSu0ttbd15HIOb5VM8P14kmgd._TileType = _EBuPkvI54JU1sFVONydkDVTfF5c; num2 = ((int)num4 * -1205964094) ^ 0x2364D6FE; continue; case 18u: { int num17; if (Settings.Default.EnableCustomNexus) { num2 = 1026700347; num17 = num2; } else { num2 = 724304106; num17 = num2; } continue; } case 1u: num2 = (int)(num4 * 1662897317) ^ -1961276272; continue; case 11u: _2CIHnoEa49dfPXyqt9nkkBlUcQf = update._Tiles; num = 0; num2 = (int)((num4 * 913737150) ^ 0x16DB2CE); continue; case 3u: jDuaG31Xe8XJ3zd9YVFcuUiYrW = new Tile(); num2 = 973742447; continue; case 10u: jDuaG31Xe8XJ3zd9YVFcuUiYrW._gNqSu0ttbd15HIOb5VM8P14kmgd = _2CIHnoEa49dfPXyqt9nkkBlUcQf[num]; num2 = ((int)num4 * -1810827798) ^ -1443243532; continue; case 0u: { int num7; int num8; if (GetTileSafety(jDuaG31Xe8XJ3zd9YVFcuUiYrW._gNqSu0ttbd15HIOb5VM8P14kmgd._PositionX, jDuaG31Xe8XJ3zd9YVFcuUiYrW._gNqSu0ttbd15HIOb5VM8P14kmgd._PositionY)) { num7 = 1353074527; num8 = num7; } else { num7 = 9589883; num8 = num7; } num2 = num7 ^ ((int)num4 * -2049079085); continue; } case 9u: num++; num2 = 1979409927; continue; case 23u: jDuaG31Xe8XJ3zd9YVFcuUiYrW._gNqSu0ttbd15HIOb5VM8P14kmgd._TileType = _slbUxvbdQHycDlSLDv7Fp9vzLwcA.ID; num2 = (int)((num4 * 608639521) ^ 0x79920E7D); continue; case 8u: { objectStructure = ResourceDownloader._VPArsrlUa0uEsW6OxAYV9WHJAMK.ById(gameObject._ObjectType); int num18; int num19; if (objectStructure != null) { num18 = 1857957430; num19 = num18; } else { num18 = 1782474652; num19 = num18; } num2 = num18 ^ ((int)num4 * -1345241816); continue; } case 15u: num2 = ((int)num4 * -454551400) ^ -1798317566; continue; case 21u: { mapStructure = CurrentClient._psKBaUvFAGf2xFOCwHRyUMbhDXG( jDuaG31Xe8XJ3zd9YVFcuUiYrW._gNqSu0ttbd15HIOb5VM8P14kmgd._PositionX, jDuaG31Xe8XJ3zd9YVFcuUiYrW._gNqSu0ttbd15HIOb5VM8P14kmgd._PositionY); int num14; int num15; if (Settings.Default.EnableSafeWalk) { num14 = -1811936846; num15 = num14; } else { num14 = -2049887611; num15 = num14; } num2 = num14 ^ (int)(num4 * 1505269834); continue; } case 14u: { int num12; int num13; if (!_qg9vWVSuFk5KWGQxb00C7qZd1yP.Any(jDuaG31Xe8XJ3zd9YVFcuUiYrW._qLjbfvpvv4ok8fhIivprcWtJuAB) ) { num12 = -851351540; num13 = num12; } else { num12 = -988112004; num13 = num12; } num2 = num12 ^ (int)(num4 * 637285689); continue; } case 5u: { int num10; int num11; if (_InShatters) { num10 = -656176903; num11 = num10; } else { num10 = -1130790076; num11 = num10; } num2 = num10 ^ ((int)num4 * -1437320632); continue; } case 20u: { int num5; int num6; if (!Settings.Default.SafeWalkInShatters) { num5 = 477215579; num6 = num5; } else { num5 = 1882433648; num6 = num5; } num2 = num5 ^ (int)(num4 * 2131303929); continue; } case 4u: return; } break; } } }