private ILocationAugmentedOptions GetOptions( LocationValuablesCollection lvc, ARLocationCollectionMechanic m) { var opts = m.AROptions ?? ARWorld.Instance.GetDefaultImageOptions(); if (lvc.CollectOptions != null && opts.VisibleRange == null) { opts.VisibleRange = lvc.CollectOptions.CollectRange; } return(opts); }
public void AllItemsCollected(string instanceId, LocationValuablesCollection lvc) { // If this is respawnable, don't close it. if (lvc.CollectOptions != null && lvc.CollectOptions.IsRespawnable.GetValueOrDefault()) { return; } ResourceActivationContext context; if (m_contexts.TryGetValue(instanceId, out context)) { context.Close(); RemoveLocationValuablesCollection(context, (LocationValuablesCollection)context.Resource); } }
public AnnotationGameObject CreateAnnotationObject(LocationValuablesCollection lvc) { if (AnnotationPrefab) { var obj = Instantiate(AnnotationPrefab); var customImageAnn = obj as CustomImageAnnotation; if (customImageAnn) { var collectible = ValuablesCollection.GetFirstCollectible(lvc.ValuablesCollection); if (collectible != null) { customImageAnn.LoadImage(collectible.ImageUrl); } } return(obj); } return(null); }
IEnumerable <KeyValuePair <ILocationCollectionDriver, ILocationCollectionMechanic> > GetDrivers(LocationValuablesCollection lvc) { if (lvc.CollectOptions != null && lvc.CollectOptions.CollectionMechanics != null) { var drivers = lvc.CollectOptions.CollectionMechanics .Where(m => m_drivers.ContainsKey(m.Type)) .Select(m => new KeyValuePair <ILocationCollectionDriver, ILocationCollectionMechanic>(m_drivers[m.Type], m)); if (drivers.Count() > 0) { return(drivers); } } if (m_defaultCollectionDriver != null) { return(new KeyValuePair <ILocationCollectionDriver, ILocationCollectionMechanic>[] { new KeyValuePair <ILocationCollectionDriver, ILocationCollectionMechanic>(m_defaultCollectionDriver, null) }); } return(null); }
public void Collect(string instanceId, Location location, LocationValuablesCollection lvc) { m_spawnItemDriver.Collect(instanceId, location, lvc); }
public LocationValuablesCollectionManagerEventArgs(ResourceActivationContext ctxt, LocationValuablesCollection lvc, bool resetState = false) { this.ResetState = resetState; LocationValuables = new LocationValuablesCollectionItemContainer[] { new LocationValuablesCollectionItemContainer(ctxt, lvc) }; }
public void RemoveLocationValuablesCollection(ResourceActivationContext context, LocationValuablesCollection lvc, bool resetState = false) { List <Location> removedLocations = null; m_contexts.Remove(context.InstanceId); m_allValuables.Remove(context.InstanceId); lock (m_valuablesByLocation) { if (lvc.Locations != null) { foreach (var l in lvc.Locations) { m_valuablesByLocation.RemoveWhere(l.Id, c => c.ActivationContext.InstanceId == context.InstanceId); if (m_valuablesByLocation[l.Id] == null || m_valuablesByLocation[l.Id].Count() == 0) { if (removedLocations == null) { removedLocations = new List <Location>(); } removedLocations.Add(l); } } } if (lvc.LocationTypes != null) { foreach (var t in lvc.LocationTypes) { m_valuablesByType.RemoveWhere(t, c => c.ValuablesCollection.Id == lvc.Id); } } if (lvc.StoryTags != null) { foreach (var t in lvc.StoryTags) { m_valuablesByTag.RemoveWhere(t, c => c.ValuablesCollection.Id == lvc.Id); } } } // Check if the collections are being updated--we don't want to // push through too many changes if we can help it. bool isUpdating; lock (this) { isUpdating = m_updating; if (isUpdating) { m_removedValuables.Add(context.InstanceId, new LocationValuablesCollectionItemContainer(context, lvc)); m_addedValuables.Remove(context.InstanceId); if (removedLocations != null) { foreach (var loc in removedLocations) { m_removedLocations[loc.Id] = loc; m_addedLocations.Remove(loc.Id); } } } } if (!isUpdating) { if (ValuablesRemoved != null) { ValuablesRemoved(this, new LocationValuablesCollectionManagerEventArgs(context, lvc, resetState)); } if (removedLocations != null && LocationsRemoved != null) { LocationsRemoved(this, new LocationValuablesCollectionManagerEventArgs(removedLocations.ToArray())); } } }
public void AddLocationValuablesCollection(ResourceActivationContext context, LocationValuablesCollection lvc) { if (context.IsClosed) { return; } context.Open(); m_contexts.Add(context.InstanceId, context); List <Location> addedLocations = null; lock (m_valuablesByLocation) { var typeTagContainer = new LocationValuablesInstance { ActivationContext = context, ValuablesCollection = lvc }; if (lvc.LocationTypes != null) { foreach (var t in lvc.LocationTypes) { m_valuablesByType.Add(t, typeTagContainer); } } if (lvc.StoryTags != null) { foreach (var t in lvc.StoryTags) { m_valuablesByTag.Add(t, typeTagContainer); } } } bool isUpdating; var container = new LocationValuablesCollectionItemContainer(context, lvc); m_allValuables.Add(context.InstanceId, container); lock (this) { isUpdating = m_updating; if (isUpdating) { m_addedValuables.Add(context.InstanceId, container); m_removedValuables.Remove(context.InstanceId); } } if (!isUpdating) { if (ValuablesAdded != null) { ValuablesAdded(this, new LocationValuablesCollectionManagerEventArgs(context, lvc)); } if (addedLocations != null && LocationsAdded != null) { LocationsAdded(this, new LocationValuablesCollectionManagerEventArgs(addedLocations.ToArray())); } } }