public void Remove(EditorActorPreview preview) { previews.Remove(preview); screenMap.Remove(preview); foreach (var kv in preview.Footprint) { List<EditorActorPreview> list; if (!cellMap.TryGetValue(kv.Key, out list)) continue; list.Remove(preview); if (!list.Any()) cellMap.Remove(kv.Key); } UpdateNeighbours(preview.Footprint); if (preview.Info.Name == "mpspawn") SyncMultiplayerCount(); }
EditorActorPreview Add(string id, ActorReference reference, bool initialSetup = false) { var owner = Players.Players[reference.InitDict.Get<OwnerInit>().PlayerName]; var preview = new EditorActorPreview(worldRenderer, id, reference, owner); previews.Add(preview); screenMap.Add(preview, preview.Bounds); foreach (var kv in preview.Footprint) { List<EditorActorPreview> list; if (!cellMap.TryGetValue(kv.Key, out list)) { list = new List<EditorActorPreview>(); cellMap.Add(kv.Key, list); } list.Add(preview); } if (!initialSetup) { UpdateNeighbours(preview.Footprint); if (reference.Type == "mpspawn") SyncMultiplayerCount(); } return preview; }
long CalculateActorSelectionPriority(EditorActorPreview actor) { var centerPixel = new int2(actor.Bounds.X, actor.Bounds.Y); var pixelDistance = (centerPixel - worldPixel).Length; // If 2+ actors have the same pixel position, then the highest appears on top. var worldZPosition = actor.CenterPosition.Z; // Sort by pixel distance then in world z position. return ((long)pixelDistance << 32) + worldZPosition; }