/// <summary> /// Copies the basic properties shared by all <see cref="HasStatsBlueprint"/> onto the target (<paramref name="onto"/>) /// </summary> /// <param name="world"></param> /// <param name="onto"></param> /// <param name="blueprint"></param> /// <param name="defaultDialogueVerb">What do you do to initiate dialogue with this T, e.g. talk, read, look around etc</param> protected virtual void AddBasicProperties(IWorld world, T2 onto, T1 blueprint, string defaultDialogueVerb) { if (blueprint.Unique) { UniquesSpawned.Add(blueprint.Identifier ?? Guid.Empty); } AddActions(world, blueprint, onto); AddBehaviours(world, blueprint, onto); onto.Color = blueprint.Color; onto.Unique = blueprint.Unique; if (blueprint.Identifier.HasValue) { onto.Identifier = blueprint.Identifier; } if (blueprint.Stats != null) { onto.BaseStats.Increase(blueprint.Stats.Clone()); } //make sure the stats listed on blueprints actually exist foreach (Stat s in onto.BaseStats.Keys) { if (!world.AllStats.Contains(s)) { throw new Exception($"Unrecognized stat '{s}' on blueprint '{onto}'. Add the stat to stats.yaml or IWorld.AllStats"); } } if (blueprint.Dialogue != null) { onto.Dialogue = blueprint.Dialogue; if (onto.Dialogue.Verb == null) { onto.Dialogue.Verb = defaultDialogueVerb; } } if (blueprint.InjurySystem != null) { IInjurySystem system; try { system = (IInjurySystem)world.GetSystem(blueprint.InjurySystem.Value); } catch (Exception e) { throw new GuidNotFoundException( $"Error looking up Injury System {blueprint.InjurySystem} for {blueprint}", e, blueprint.InjurySystem.Value); } onto.InjurySystem = system; } }
/// <summary> /// True if the blueprint should be included in randomization choices /// </summary> /// <param name="b"></param> /// <returns></returns> public virtual bool Spawnable(HasStatsBlueprint b) { //don't return fixed location stuff as a random choice if (b is RoomBlueprint r && r.FixedLocation != null) { return(false); } if (!b.Unique) { return(true); } return(!UniquesSpawned.Contains(b.Identifier ?? Guid.Empty)); }