public void Build(BuildableType buildableType) { foreach (GameBuildableNode buildableNode in buildables) { if (buildableType == buildableNode.buildableType && CanWithdraw(buildableNode.costType, buildableNode.cost)) { WithDraw(buildableNode.costType, buildableNode.cost); } } }
public bool CanBuild(BuildableType buildableType) { foreach (GameBuildableNode buildableNode in buildables) { if (buildableType == buildableNode.buildableType && CanWithdraw(buildableNode.costType, buildableNode.cost)) { return(true); } } return(false); }
protected Buildable(BuildablePrototype b) { this.name = b.name; this.sprite = Sprite_Manager.instance.GetSprite(b.sprite); this.animatorController = Sprite_Manager.instance.GetAnimator(b.animatorController); this.buildableType = b.buildableType; this.stats = new Stat[b.stats.Length]; for (int i = 0; i < this.stats.Length; i++) { this.stats[i] = new Stat(b.stats[i].statType, b.stats[i].minValue, b.stats[i].maxValue); } }
protected Buildable(string name, string _sprite, string animatorName, BuildableType buildType, Stat[] bStats) { this.name = name; if (Sprite_Manager.instance != null) { this.sprite = Sprite_Manager.instance.GetSprite(_sprite); this.animatorController = Sprite_Manager.instance.GetAnimator(animatorName); } this.buildableType = buildType; this.stats = new Stat[bStats.Length]; for (int i = 0; i < this.stats.Length; i++) { this.stats[i] = new Stat(bStats[i].statType, bStats[i].minValue, bStats[i].maxValue); } }
private GameObject SpawnBuildable <T>(T buildable, BuildableType buildableType, Vector2 position) { if (buildable == null) { return(null); } GameObject gObj = pool.GetObjectForType(buildableType.ToString(), true, position); if (gObj == null) { return(null); } gObj.transform.SetParent(ShipManager.instance.transform); // Does this buildable require an Inventory Controller? Buildable b = buildable as Buildable; if (b != null && b.GetStat(StatType.Storage) != null) { GameObject invController = pool.GetObjectForType("Inventory Controller", true, position); invController.transform.SetParent(gObj.transform); //invController.GetComponent<Inventory_Controller>().Initialize(b.name, b.GetStat(StatType.Storage).GetValue()); } return(gObj); }
private static void ProcessElements(IRocketPlayer caller, ushort itemID, float radius, WreckType type, FlagType flagtype, List <char> Filter, bool pInfoLibLoaded, object region, Vector3 position, ulong steamID, BuildableType buildType) { StructureRegion sRegion = null; BarricadeRegion bRegion = null; BarricadeData bData = null; StructureData sData = null; bool isSRegion = region is StructureRegion; int DataCount; int transformCount; if (isSRegion) { sRegion = region as StructureRegion; transformCount = sRegion.drops.Count; DataCount = sRegion.structures.Count; } else { bRegion = region as BarricadeRegion; transformCount = bRegion.drops.Count; DataCount = bRegion.barricades.Count; } for (int i = 0; i < transformCount; i++) { Transform transform = isSRegion ? sRegion.drops[i].model : bRegion.drops[i].model; ulong owner; if (i < DataCount) { if (isSRegion) { sData = sRegion.structures[i]; owner = sData.owner; } else { bData = bRegion.barricades[i]; owner = bData.owner; } } else { Logger.LogWarning(WreckingBall.Instance.Translate(isSRegion ? "wreckingball_structure_array_sync_error" : "wreckingball_barricade_array_sync_error")); syncError = true; break; } float distance = Vector3.Distance(transform.position, position); if (((!radius.IsNaN() && distance <= radius) || (radius.IsNaN() && (transform.position.x.IsNaN() || transform.position.y.IsNaN() || transform.position.z.IsNaN()))) && type != WreckType.Cleanup && type != WreckType.Counts) { ushort item = isSRegion ? sData.structure.id : bData.barricade.id; if (WreckingBall.ElementData.FilterItem(item, Filter) || Filter.Contains('*') || flagtype == FlagType.ItemID) { if (flagtype == FlagType.Normal) { WreckProcess(caller, item, distance, pInfoLibLoaded, buildType, type, isSRegion ? (object)sData : bData, transform); } else if (flagtype == FlagType.SteamID && owner == steamID) { WreckProcess(caller, item, distance, pInfoLibLoaded, buildType, type, isSRegion ? (object)sData : bData, transform); } else if (flagtype == FlagType.ItemID && itemID == item) { WreckProcess(caller, item, distance, pInfoLibLoaded, buildType, type, isSRegion ? (object)sData : bData, transform); } } } else if (type == WreckType.Cleanup && owner == steamID) { cleanupList.Add(new Destructible(transform, isSRegion ? ElementType.Structure : ElementType.Barricade, isSRegion ? sData.structure.id : bData.barricade.id)); } else if (type == WreckType.Counts) { if (pElementCounts.ContainsKey(owner)) { pElementCounts[owner]++; } else { pElementCounts.Add(owner, 1); } } } }
private static void WreckProcess(IRocketPlayer caller, ushort itemID, float distance, bool pInfoLibLoaded, BuildableType buildType, WreckType type, object data, Transform transform, int count = 0, ulong lockedOwner = 0, int vindex = 0) { if (type == WreckType.Scan) { if (distance <= 10) { WreckingBall.ElementData.Report(caller, itemID, distance, true, pInfoLibLoaded, data, buildType, count, lockedOwner, vindex); } else { WreckingBall.ElementData.Report(caller, itemID, distance, false, pInfoLibLoaded, data, buildType); } } else { if (data is StructureData) { destroyList.Add(new Destructible(transform, ElementType.Structure, itemID)); } if (data is BarricadeData) { destroyList.Add(new Destructible(transform, ElementType.Barricade, itemID)); } // Add the vehicle to the destruction list, as long as it's not a train. Allow a special case where you could destroy a train from using wreck on the console, only. if (data is InteractableVehicle && (((InteractableVehicle)data).asset.engine != EEngine.TRAIN || caller is ConsolePlayer && vindex == 0 && type != WreckType.Counts && type != WreckType.Cleanup)) { destroyList.Add(new Destructible(transform, ElementType.Vehicle, itemID, data as InteractableVehicle)); } if (data is Zombie) { destroyList.Add(new Destructible(transform, ElementType.Zombie, itemID, null, data as Zombie)); } if (data is Animal) { destroyList.Add(new Destructible(transform, ElementType.Animal, itemID, null, null, data as Animal)); } } }
internal void Report(IRocketPlayer caller, ushort itemId, float range, bool printConsole, bool getPinfo, object data, BuildableType type = BuildableType.Element, int count = 0, ulong lockedOwner = 0, int vindex = 0) { Category cat; if (!elements.ContainsKey(itemId)) { if (type == BuildableType.VehicleElement) { if (reportLists[BuildableType.VehicleElement].ContainsKey('!')) { reportLists[BuildableType.VehicleElement]['!'] += 1; } else { reportLists[BuildableType.VehicleElement].Add('!', 1); } cat = categorys['!']; } else { if (reportLists[BuildableType.Element].ContainsKey('!')) { reportLists[BuildableType.Element]['!'] += 1; } else { reportLists[BuildableType.Element].Add('!', 1); } cat = categorys['!']; } } else { if (type == BuildableType.VehicleElement) { if (reportLists[BuildableType.VehicleElement].ContainsKey(elements[itemId].CategoryId)) { reportLists[BuildableType.VehicleElement][elements[itemId].CategoryId] += 1; } else { reportLists[BuildableType.VehicleElement].Add(elements[itemId].CategoryId, 1); } cat = categorys[elements[itemId].CategoryId]; } else { if (reportLists[BuildableType.Element].ContainsKey(elements[itemId].CategoryId)) { reportLists[BuildableType.Element][elements[itemId].CategoryId] += 1; } else { reportLists[BuildableType.Element].Add(elements[itemId].CategoryId, 1); } cat = categorys[elements[itemId].CategoryId]; } } if (printConsole || !elements.ContainsKey(itemId)) { string stype = type == BuildableType.VehicleElement ? "Vehicle Element: " : "Element: "; string msg = string.Empty; ulong owner = 0; InteractableVehicle vehicle = null; StructureData sData = null; BarricadeData bData = null; string eName = string.Empty; if (data is BarricadeData) { bData = data as BarricadeData; owner = bData.owner; eName = bData.barricade.asset.itemName; } else if (data is StructureData) { sData = data as StructureData; owner = sData.owner; eName = sData.structure.asset.itemName; } else if (data is InteractableVehicle) { vehicle = data as InteractableVehicle; itemId = vehicle.id; eName = vehicle.asset.vehicleName; } if (type == BuildableType.Vehicle) { DestructionProcessing.HasFlaggedElement(vindex > 0 ? vehicle.trainCars[vindex].root : vehicle.transform, out ulong signOwner); msg = string.Format("{0}{1} (Id: {6}:{2}, Instance ID: {8}) @ {3}m, Barricade Count: {4}, Sign by: {7}, Locked By: {5}", stype, cat.Name, itemId, Math.Round(range, 2), count, lockedOwner > 0 ? getPinfo ? WreckingBall.Instance.PInfoGenerateMessage(lockedOwner) : lockedOwner.ToString() : "N/A", vindex > 0 ? "Train car#" + vindex : eName, signOwner > 0 ? getPinfo ? WreckingBall.Instance.PInfoGenerateMessage(signOwner) : signOwner.ToString() : "N/A", vehicle.instanceID.ToString()); } else { // Generate the message in another method, as the Player info one requires special data types that have to be loaded before executing a method. msg = string.Format("{0}{1} (Id: {5}:{2}) @ {3}m, Owner: {4}", stype, cat.Name, itemId, Math.Round(range, 2), owner > 0 ? getPinfo ? WreckingBall.Instance.PInfoGenerateMessage(owner) : owner.ToString() : "N/A", eName); } if (WreckingBall.Instance.Configuration.Instance.LogScans) { Logger.Log(msg, cat.Color); } else { Console.ForegroundColor = cat.Color; Console.WriteLine(msg); Console.ResetColor(); if (R.Settings.Instance.RCON.Enabled) { RCONServer.Broadcast(msg); } } if (WreckingBall.Instance.Configuration.Instance.PrintToChat && !(caller is ConsolePlayer)) { UnturnedChat.Say(caller, msg, Color.yellow); } } }