private void OnEnable() { if (ActionGameManager.Instance.DockedEntity is OrbitalEntity orbital) { _currentLocation = orbital.Story; _activeStory = _currentLocation.Story; } else { return; } Continue(); }
public void ProcessLocation(Story story, FileInfo inkFile) { if (_placedStories.ContainsKey(story)) { return; // Don't place already placed stories, idiot! } _placedStories[story] = null; // Avoids potential for infinite loops when evaluating constraints var fileName = Path.GetFileNameWithoutExtension(inkFile.FullName); var contentTags = GetContentTags(story.globalTags); var constraints = new List <ZoneConstraint>(); if (contentTags.ContainsKey("constraint")) { foreach (var constraintString in contentTags["constraint"]) { var args = constraintString.Split(' '); var flip = args[0] == "not"; if (flip) { args = args.Skip(1).ToArray(); } var constraintName = args[0]; args = args.Skip(1).ToArray(); ZoneConstraint constraint = constraintName switch { "DistanceFrom" => new DistanceConstraint(args, this) { Flip = flip }, "FactionPresent" => new FactionPresenceConstraint(args, this) { Flip = flip }, "FactionOwner" => new FactionOwnerConstraint(args, this) { Flip = flip }, _ => null }; if (constraint != null) { constraints.Add(constraint); } } } ZoneSelector selector; if (contentTags.ContainsKey("select")) { var selectorString = contentTags["select"].First(); var args = selectorString.Split(' '); var flip = args[0] == "not"; if (flip) { args = args.Skip(1).ToArray(); } var selectorName = args[0]; args = args.Skip(1).ToArray(); selector = selectorName switch { "DistanceFrom" => new DistanceSelector(args, this) { Flip = flip }, _ => new RandomSelector(ref _random) }; } else { selector = new RandomSelector(ref _random); } var zoneCandidates = new List <GalaxyZone>(); zoneCandidates.AddRange(Galaxy.Zones.Where(z => !z.NamedZone && constraints.All(c => c.Test(z)))); var zone = selector.SelectZone(zoneCandidates); var location = new LocationStory { Zone = zone, FileName = fileName, Name = contentTags.ContainsKey("name") ? contentTags["name"].First() : fileName, Faction = contentTags.ContainsKey("faction") ? ResolveFaction(contentTags["faction"].First()) : zone.Owner, Security = contentTags.ContainsKey("security") ? (SecurityLevel)Enum.Parse(typeof(SecurityLevel), contentTags["security"].First(), true) : SecurityLevel.Open, Story = story, Type = contentTags.ContainsKey("type") ? (LocationType)Enum.Parse(typeof(LocationType), contentTags["type"].First(), true) : LocationType.Station, Turrets = contentTags.ContainsKey("turrets") ? int.Parse(contentTags["turrets"].First()) : 0 }; zone.Locations.Add(location); if (contentTags.ContainsKey("namezone")) { zone.Name = contentTags["namezone"].First(); } _placedStories[story] = location; }