private Element FindElement(ExtElemReference reference)
        {
            if (!cache.ContainsKey(reference))
            {
                var elem = Game.Instance.GameState.FindElement <Element>(reference.getTargetId());
                cache.Add(reference, elem);
            }

            return(cache.ContainsKey(reference) ? cache[reference] : null);
        }
Example #2
0
 public ExtElementRefDataControl(ExtElemReference extElemReference) : base(extElemReference)
 {
     this.extElemReference = extElemReference;
     type = getReferenceType(extElemReference.getTargetId());
     this.transformManagerDataControl = new TransformManagerDataControl(this);
 }
        public ExtElementRefDataControl(ExtElemReference extElemReference) : base(extElemReference)
        {
            this.extElemReference = extElemReference;
            type = getReferenceType(extElemReference.getTargetId());
            this.transformManagerDataControl = new TransformManagerDataControl(this);

            geoActionDataControls = new ListDataControl <ExtElementRefDataControl, GeoActionDataControl>(this, extElemReference.Actions, new []
            {
                new ListDataControl <ExtElementRefDataControl, GeoActionDataControl> .ElementFactoryView
                {
                    Titles =
                    {
                        { GeoElementDataControl.ENTER_ACTION,   "Geo.Create.Title.EnterAction"  },
                        { GeoElementDataControl.EXIT_ACTION,    "Geo.Create.Title.ExitAction"   },
                        { GeoElementDataControl.LOOK_TO_ACTION, "Geo.Create.Title.LookToAction" }
                    },
                    Messages =
                    {
                        { GeoElementDataControl.ENTER_ACTION,   "Geo.Create.Message.EnterAction"  },
                        { GeoElementDataControl.EXIT_ACTION,    "Geo.Create.Message.ExitAction"   },
                        { GeoElementDataControl.LOOK_TO_ACTION, "Geo.Create.Message.LookToAction" }
                    },
                    Errors =
                    {
                        { GeoElementDataControl.ENTER_ACTION,   "Geo.Create.Error.EnterAction"  },
                        { GeoElementDataControl.EXIT_ACTION,    "Geo.Create.Error.ExitAction"   },
                        { GeoElementDataControl.LOOK_TO_ACTION, "Geo.Create.Error.LookToAction" }
                    },
                    ElementFactory = new DefaultElementFactory <GeoActionDataControl>(new DefaultElementFactory <GeoActionDataControl> .ElementCreator()
                    {
                        TypeDescriptors = new []
                        {
                            new TD
                            {
                                Type        = GeoElementDataControl.ENTER_ACTION,
                                ContentType = typeof(EnterAction)
                            },
                            new TD
                            {
                                Type        = GeoElementDataControl.EXIT_ACTION,
                                ContentType = typeof(ExitAction)
                            },
                            new TD
                            {
                                Type        = GeoElementDataControl.LOOK_TO_ACTION,
                                ContentType = typeof(InspectAction)
                            }
                        },
                        CreateDataControl = action => new GeoActionDataControl(action as GeoAction),
                        CreateElement     = (type, id, _) =>
                        {
                            switch (type)
                            {
                            case GeoElementDataControl.ENTER_ACTION:   return(new GeoActionDataControl(new EnterAction()));

                            case GeoElementDataControl.EXIT_ACTION:    return(new GeoActionDataControl(new ExitAction()));

                            case GeoElementDataControl.LOOK_TO_ACTION: return(new GeoActionDataControl(new LookToAction()));

                            default: return(null);
                            }
                        }
                    })
                }
            });
        }