public void SelectTool(ThingTypes thingType, bool animateIfIdenticalThingType) { if (selectedThingType == thingType && !animateIfIdenticalThingType) { return; } if (tool != null) { Destroy(tool); } if (!ThingFactory.IsTool(thingType)) { Debug.LogError("ToolGUI.SelectTool got non-tool. " + thingType); return; } selectedThingType = thingType; isMoving = true; moveTimer = 0; tool = Instantiate(GetToolGUIPrefab(thingType)) as GameObject; tool.transform.parent = player.transform; tool.transform.position = toolDownTransform.position; tool.transform.rotation = toolDownTransform.rotation; }
public void AddRequiredThing(ThingTypes thingType, int requiredQuantity) { //this node will require a quantity of this thing BlueprintNodeTask nodeTask = new BlueprintNodeTask(requiredQuantity, thingType); GetNodeTasks().Add(nodeTask); }
private static GameObject GetStructurePrefab(ThingTypes thingType) { if (structurePrefabs == null) { structurePrefabs = new Dictionary <ThingTypes, GameObject>(); } if (!ThingFactory.IsBlueprint(thingType)) { Debug.LogError("GetStructurePrefab got thingType that isn't a blueprint. " + thingType); return(null); } if (!structurePrefabs.ContainsKey(thingType)) { Thing thingTemplate = ThingFactory.MakeThing(thingType); string path = "structures/" + thingTemplate.key; GameObject structurePrefab = Resources.Load(path) as GameObject; if (structurePrefab == null) { Debug.LogError("GetStructurePrefab failed to load prefab: " + path); } structurePrefabs.Add(thingType, structurePrefab); } return(structurePrefabs[thingType]); }
public void SetAudioClip(ThingTypes thingType) { if (thingType == ThingTypes.greasegun || thingType == ThingTypes.hammerdrill || thingType == ThingTypes.shovel || thingType == ThingTypes.wrench || thingType == ThingTypes.electricdrill) { if (audioClips == null) { audioClips = new Dictionary <string, AudioClip>(); } string filename = ThingFactory.GetKeyFromThingType(thingType); string path = "sounds/tools/" + filename; if (!audioClips.ContainsKey(path)) { audioClip = Resources.Load(path) as AudioClip; if (audioClip == null) { Debug.LogError("Expected to find an audioclip, but did not. '" + path + "'"); } audioClips.Add(path, audioClip); } audioClip = audioClips[path]; } }
//When I first spawn a world thing I need to run setup on it so that it does basic stuff like place itself public ActorModel(TileModel start, ThingTypes thingType) { ID = Guid.NewGuid(); Type = thingType; SetLocation(start); if (!ModelManager.AllThings.ContainsKey(ID)) { ModelManager.AllThings.Add(ID, this); } switch (thingType) { case ThingTypes.Skeleton: Species = God.Library.GetRandomMonster().Type; AddTrait(Traits.Monster); break; case ThingTypes.Player: AddTrait(Traits.Player); break; case ThingTypes.ScoreThing: AddTrait(Traits.Score); break; case ThingTypes.RedKey: AddTrait(Traits.Key); break; case ThingTypes.MagicDoor: AddTrait(Traits.Door); break; } }
public static Thing MakeThing(ThingTypes thingType) { //makes a deep copy off the correct thingTemplate. from python import deepcopy plz Thing template = thingTemplates [thingType]; Thing newThing = new Thing(); newThing.iconTexture = template.iconTexture; newThing.thingType = template.thingType; newThing.key = template.key; newThing.name = template.name; newThing.longName = template.longName; newThing.isBlueprint = template.isBlueprint; newThing.isTool = template.isTool; newThing.workVerb = template.workVerb; newThing.maxDurability = template.maxDurability; //dependent data newThing.durability = template.durability; newThing.quantity = template.quantity; if (newThing.quantity == 0) { newThing.quantity = 1; } return(newThing); }
public void AddRequiredTool(ThingTypes toolThingType, float requiredWork) { //this node will require work done with this tool type. BlueprintNodeTask nodeTask = new BlueprintNodeTask(requiredWork, toolThingType); GetNodeTasks().Add(nodeTask); }
public static GameObject MakeStructure(ThingTypes thingType, bool isBlueprint) { if (!ThingFactory.IsBlueprint(thingType)) { Debug.LogError("StructureFactory.MakeStructure got a non-blueprint thingType: " + thingType); return(null); } GameObject prefab = GetStructurePrefab(thingType); GameObject structure = Instantiate(prefab) as GameObject; StructureController sc = structure.GetComponent <StructureController>(); if (isBlueprint) { sc.SetupBlueprint(); } else { sc.SetupRealStructure(); } if (isBlueprint) { ParentChildFunctions.SetMaterialOfChildren(structure, Blueprint.GetBlueprintMaterial()); ParentChildFunctions.SetCollisionForChildren(structure, false); } else if (!sc.HasColliders()) { //real structures with no colliders get mesh colliders ParentChildFunctions.SetCollisionForChildren(structure, !isBlueprint); } return(structure); }
public static string GetKeyFromThingType(ThingTypes thingType) { if (!isSetup) { Setup(); } return(thingTemplates [thingType].key); }
public BlueprintNodeTask(int quantityRequired, ThingTypes requiredThingType) { isSet = true; nodeMode = BlueprintNode.NodeModes.thing; this.quantityRequired = quantityRequired; quantityFilled = 0; this.requiredThingType = requiredThingType; }
public static bool IsBlueprintVisor(ThingTypes thingType) { //returns true if this thing is a VR visor that projects blueprints if (!isSetup) { Setup(); } return(thingType == ThingTypes.vrvisor); }
public static BlueprintDesign GetDefaultDesignFromThingType(ThingTypes thingType) { if (!thingTypeDesigns.ContainsKey(thingType)) { GetDefaultDesign(thingType); } return(thingTypeDesigns[thingType]); }
public static bool IsBlueprint(ThingTypes thingType) { //returns true if this thing can be laid down as a rotating blueprint. if (!isSetup) { Setup(); } return(blueprintThingTypes.Contains(thingType)); }
public static bool IsTool(ThingTypes thingType) { //returns true if this thing is a handheld tool and shown in front of the camera when selected. if (!isSetup) { Setup(); } return(toolThingTypes.Contains(thingType)); }
public void AddTool(ThingTypes requiredThingType, float energyPerNode, int replacedNodeCount, string nodeSubstring) { //see comments for AddThing. DesignRequirement dr = new DesignRequirement(requiredThingType); dr.SetWorkRequirement(energyPerNode); dr.SetSubstringLocation(nodeSubstring, replacedNodeCount); AddDesignRequirement(dr); }
public IThingINeed Create(ThingTypes thingType) { string dependencyName = "Thing" + thingType; if (_container.IsRegistered <IThingINeed>(dependencyName)) { return(_container.Resolve <IThingINeed>(dependencyName)); } return(_container.Resolve <IThingINeed>()); }
public Thing FindThingFromInventory(ThingTypes thingType) { foreach (Thing thing in inventory) { if (thing != null && thing.thingType == thingType) { return(thing); } } return(null); }
public void AddThing(ThingTypes requiredThingType, int quantity, Vector3 position) { //adds a thing requirement for this blueprint design. //adds one node that needs "quantity" number of "requiredThingType", offset by "position" DesignRequirement dr = new DesignRequirement(requiredThingType); dr.SetVectorLocation(position); dr.SetThingRequirement(quantity); AddDesignRequirement(dr); }
public BlueprintNodeTask(float workRequired, ThingTypes requiredThingType) { isSet = true; nodeMode = BlueprintNode.NodeModes.work; this.workRequired = workRequired; workFilled = 0; this.requiredThingType = requiredThingType; SetAudioClip(requiredThingType); }
private void SetupGeneric() { //this stuff happens for blueprint structures and real structures //static SetThingStructurePairs(); structureControllerCount++; matchingThingType = thingAndStructurePairs [structureType]; matchingThing = ThingFactory.MakeThing(matchingThingType); structureInfo = new StructureInfo(matchingThingType); }
public string PerformSomeFunction(ThingTypes valueThatDeterminesTypeOfThing) { var thingINeed = _factory.Create(valueThatDeterminesTypeOfThing); try { return(thingINeed.GetType().Name); } finally { _factory.Release(thingINeed); } }
public static List <ActorModel> GetThings(ThingTypes thingType = ThingTypes.None) { List <ActorModel> r = new List <ActorModel>(); foreach (ActorModel wt in GetActors()) { if (thingType == ThingTypes.None || wt.Type == thingType) { r.Add(wt); } } return(r); }
private static GameObject GetToolGUIPrefab(ThingTypes thingType) { if (!toolGUIPrefabs.ContainsKey(thingType)) { string path = "gui/" + ThingFactory.GetKeyFromThingType(thingType); GameObject toolGUIPrefab = Resources.Load(path) as GameObject; if (toolGUIPrefab == null) { Debug.LogError("GetToolGUIPrefab failed to load prefab: " + path); } toolGUIPrefabs.Add(thingType, toolGUIPrefab); } return(toolGUIPrefabs [thingType]); }
public void AddThing(ThingTypes requiredThingType, int quantityPerNode, int replacedNodeCount, string nodeSubstring) { //adds a thing requirement for this blueprint design. //requiredThingType is the needed thing //nodeSubstring is used to help Blueprint build its BlueprintNodes. It uses nodeSubstring to find which GameObjects //to replace with a node. //quantityPerNode is how many requiredThingTypes are needed per node. replacedNodeCount is how many nodes to create. DesignRequirement dr = new DesignRequirement(requiredThingType); dr.SetSubstringLocation(nodeSubstring, replacedNodeCount); dr.SetThingRequirement(quantityPerNode); AddDesignRequirement(dr); }
public static Thing Create( long id, ThingTypes thingType, string name, ISlotList validSlots, IMaybe <EquipmentSlots> equipedAs) { return(new Thing( id, thingType, name, validSlots, equipedAs, Maybe <CombatStatistics> .None, ImmutableDictionary <long, Thing> .Empty)); }
public string PerformSomeFunction(ThingTypes valueThatDeterminesTypeOfThing) { var thingINeed = _factory.Create(valueThatDeterminesTypeOfThing); try { //This is just for demonstration purposes. The method //returns the name of the type created by the factory //so you can tell that the factory worked. return(thingINeed.GetType().Name); } finally { _factory.Release(thingINeed); } }
public ActorModel(TileModel start, ThingTypes thingType) { ID = Guid.NewGuid(); Type = thingType; SetLocation(start); if (!ModelManager.AllActors.ContainsKey(ID)) { ModelManager.AllActors.Add(ID, this); } switch (thingType) { case ThingTypes.Monster: //Species = God.Library.GetRandomMonster().Type; //AddTrait(Traits.Monster); if (God.MonsterSwitch) { Species = God.Library.Monsters[1].Type; Debug.Log(Species); God.MonsterSwitch = false; AddTrait(Traits.Monster); } else if (!God.MonsterSwitch) { Species = God.Library.Monsters[0].Type; Debug.Log(Species); God.MonsterSwitch = true; AddTrait(Traits.Monster); } break; case ThingTypes.Player: AddTrait(Traits.Player); break; case ThingTypes.ScoreThing: AddTrait(Traits.Score); break; case ThingTypes.RedKey: AddTrait(Traits.Key); break; case ThingTypes.MagicDoor: AddTrait(Traits.Door); break; } }
public static Thing Create( long id, ThingTypes thingType, string name, ISlotList validSlots, IMaybe <EquipmentSlots> equipedAs, IMaybe <CombatStatistics> combatStatistics, IThingStore contains) { return(new Thing( id, thingType, name, validSlots, equipedAs, combatStatistics, contains)); }
public static BlueprintDesign GetDefaultDesign(ThingTypes thingType) { if (thingTypeDesigns.ContainsKey(thingType)) { return(thingTypeDesigns[thingType]); } BlueprintDesign bd = new BlueprintDesign(); bd.thingType = thingType; AddBuildRequirements(bd); if (!bd.IsSet()) { Debug.LogError("GetDefaultDesign did not set the BlueprintDesign at all for: " + thingType); } blueprintDesigns.Add(bd); thingTypeDesigns.Add(thingType, bd); return(bd); }
public Thing( long id, ThingTypes thingType, string name, ISlotList validSlots, IMaybe <EquipmentSlots> equipedAs, IMaybe <CombatStatistics> combatStatistics, IThingStore contains) { Debug.Assert(name != null); Debug.Assert(validSlots != null); Debug.Assert(equipedAs != null); Debug.Assert(combatStatistics != null); Debug.Assert(contains != null); _id = id; _thingType = thingType; _name = name; _validSlots = validSlots; _equipedAs = equipedAs; _combatStatistics = combatStatistics; _contains = contains; }