本文整理汇总了C#中IMyEntity.getBestName方法的典型用法代码示例。如果您正苦于以下问题:C# IMyEntity.getBestName方法的具体用法?C# IMyEntity.getBestName怎么用?C# IMyEntity.getBestName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMyEntity
的用法示例。
在下文中一共展示了IMyEntity.getBestName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Waypoint
public Waypoint(Mover mover, AllNavigationSettings navSet, AllNavigationSettings.SettingsLevelName level, IMyEntity targetEntity, Vector3D worldOffset)
: base(mover, navSet)
{
this.m_logger = new Logger(GetType().Name, m_controlBlock.CubeBlock);
this.m_level = level;
this.m_targetEntity = targetEntity;
this.m_targetOffset = worldOffset;
m_logger.debugLog(targetEntity != targetEntity.GetTopMostParent(), "targetEntity is not top-most", Logger.severity.FATAL);
IMyCubeGrid asGrid = targetEntity as IMyCubeGrid;
if (asGrid != null && Attached.AttachedGrid.IsGridAttached(asGrid, m_controlBlock.CubeGrid, Attached.AttachedGrid.AttachmentKind.Physics))
{
m_logger.debugLog("Cannot fly to entity, attached: " + targetEntity.getBestName() + ", creating GOLIS", Logger.severity.WARNING);
new GOLIS(mover, navSet, TargetPosition, level);
return;
}
if (targetEntity.Physics == null)
{
m_logger.debugLog("Target has no physics: " + targetEntity.getBestName() + ", creating GOLIS", Logger.severity.WARNING);
new GOLIS(mover, navSet, TargetPosition, level);
return;
}
var setLevel = navSet.GetSettingsLevel(level);
setLevel.NavigatorMover = this;
//setLevel.DestinationEntity = mover.Block.CubeBlock; // to force avoidance
m_logger.debugLog("created, level: " + level + ", target: " + targetEntity.getBestName() + ", target position: " + targetEntity.GetPosition() + ", offset: " + worldOffset + ", position: " + TargetPosition, Logger.severity.DEBUG);
}
示例2: GuidedMissile
/// <summary>
/// Creates a missile with homing and target finding capabilities.
/// </summary>
public GuidedMissile(IMyEntity missile, IMyCubeBlock firedBy, TargetingOptions opt, Ammo ammo, LastSeen initialTarget = null, bool isSlave = false)
: base(missile, firedBy)
{
myLogger = new Logger("GuidedMissile", () => missile.getBestName(), () => m_stage.ToString());
myAmmo = ammo;
myDescr = ammo.Description;
if (ammo.Description.HasAntenna)
myAntenna = new MissileAntenna(missile);
TryHard = true;
AllGuidedMissiles.Add(this);
missile.OnClose += missile_OnClose;
if (myAmmo.IsCluster && !isSlave)
myCluster = new Cluster(myAmmo.MagazineDefinition.Capacity - 1);
accelerationPerUpdate = (myDescr.Acceleration + myAmmo.MissileDefinition.MissileAcceleration) / 60f;
addSpeedPerUpdate = myDescr.Acceleration / 60f;
Options = opt;
Options.TargetingRange = ammo.Description.TargetRange;
myTargetSeen = initialTarget;
myLogger.debugLog("Options: " + Options, "GuidedMissile()");
//myLogger.debugLog("AmmoDescription: \n" + MyAPIGateway.Utilities.SerializeToXML<Ammo.AmmoDescription>(myDescr), "GuidedMissile()");
}
示例3: AddWeaponsTargetingProjectile
private static void AddWeaponsTargetingProjectile(IMyEntity entity, short number)
{
s_logger.debugLog("entity: " + entity.getBestName() + ", number: " + number, "AddWeaponsTargetingProjectile()");
short count;
if (WeaponsTargetingProjectile.TryGetValue(entity.EntityId, out count))
{
s_logger.debugLog("count: " + count, "AddWeaponsTargetingProjectile()");
count += number;
if (count == zero)
{
WeaponsTargetingProjectile.Remove(entity.EntityId);
return;
}
s_logger.debugLog(count < zero, "count is negative: " + count + ", for " + entity.getBestName(), "AddWeaponsTargetingProjectile()", Logger.severity.FATAL);
}
else
count = number;
s_logger.debugLog(count > short.MaxValue / 2, "many weapons targeting: " + entity.getBestName() + ", count: " + count, "AddWeaponsTargetingProjectile()", Logger.severity.WARNING);
WeaponsTargetingProjectile[entity.EntityId] = count;
}
示例4: GuidedMissile
/// <summary>
/// Creates a missile with homing and target finding capabilities.
/// </summary>
public GuidedMissile(IMyEntity missile, GuidedMissileLauncher launcher, out Target initialTarget)
: base(missile, launcher.CubeBlock)
{
myLogger = new Logger("GuidedMissile", () => missile.getBestName(), () => m_stage.ToString());
m_launcher = launcher;
myAmmo = launcher.loadedAmmo;
m_owner = launcher.CubeBlock.OwnerId;
if (myAmmo.Description.HasAntenna)
myAntenna = new RelayNode(missile, () => m_owner, ComponentRadio.CreateRadio(missile, 0f));
TryHard = true;
SEAD = myAmmo.Description.SEAD;
AllGuidedMissiles.Add(this);
MyEntity.OnClose += MyEntity_OnClose;
acceleration = myDescr.Acceleration + myAmmo.MissileDefinition.MissileAcceleration;
addSpeedPerUpdate = myDescr.Acceleration * Globals.UpdateDuration;
if (!(launcher.CubeBlock is Sandbox.ModAPI.Ingame.IMyLargeTurretBase))
m_rail = new RailData(Vector3D.Transform(MyEntity.GetPosition(), CubeBlock.WorldMatrixNormalizedInv));
Options = m_launcher.m_weaponTarget.Options.Clone();
Options.TargetingRange = myAmmo.Description.TargetRange;
RelayStorage storage = launcher.m_relayPart.GetStorage();
if (storage == null)
{
myLogger.debugLog("failed to get storage for launcher", Logger.severity.WARNING);
}
else
{
myLogger.debugLog("getting initial target from launcher", Logger.severity.DEBUG);
GetLastSeenTarget(storage, myAmmo.MissileDefinition.MaxTrajectory);
}
initialTarget = CurrentTarget;
if (myAmmo.RadarDefinition != null)
{
myLogger.debugLog("Has a radar definiton");
m_radar = new RadarEquipment(missile, myAmmo.RadarDefinition, launcher.CubeBlock);
if (myAntenna == null)
{
myLogger.debugLog("Creating node for radar");
myAntenna = new RelayNode(missile, () => m_owner, null);
}
}
Registrar.Add(missile, this);
myLogger.debugLog("Options: " + Options + ", initial target: " + (myTarget == null ? "null" : myTarget.Entity.getBestName()));
//myLogger.debugLog("AmmoDescription: \n" + MyAPIGateway.Utilities.SerializeToXML<Ammo.AmmoDescription>(myDescr), "GuidedMissile()");
}
示例5: Grid_OnClosing
/// <summary>
/// unregister events for grid
/// </summary>
private void Grid_OnClosing(IMyEntity gridAsEntity)
{
myLogger.debugLog("entered Grid_OnClosing(): " + gridAsEntity.getBestName());
IMyCubeGrid asGrid = gridAsEntity as IMyCubeGrid;
asGrid.OnBlockAdded -= Grid_OnBlockAdded;
asGrid.OnClosing -= Grid_OnClosing;
myLogger.debugLog("leaving Grid_OnClosing(): " + gridAsEntity.getBestName());
}
示例6: AddEntity
/// <summary>
/// if necessary, builds script for an entity
/// </summary>
/// <param name="entity"></param>
private void AddEntity(IMyEntity entity)
{
// the save flag is often on initially and disabled after
if (!(entity.Save || entity is IMyCharacter))
return;
//myLogger.debugLog("adding entity: " + entity.getBestName() + ", flags: " + entity.Flags + ", persistent: " + entity.PersistentFlags, "AddEntity()");
IMyCubeGrid asGrid = entity as IMyCubeGrid;
if (asGrid != null)
{
//myLogger.debugLog("adding grid: " + asGrid.DisplayName + ", flags: " + asGrid.Flags + ", persistent: " + asGrid.PersistentFlags, "AddEntity()");
//myLogger.debugLog("save: " + asGrid.Save, "AddEntity()");
List<IMySlimBlock> blocksInGrid = new List<IMySlimBlock>();
asGrid.GetBlocks(blocksInGrid, slim => slim.FatBlock != null);
foreach (IMySlimBlock slim in blocksInGrid)
AddBlock(slim);
asGrid.OnBlockAdded += Grid_OnBlockAdded;
asGrid.OnClosing += Grid_OnClosing;
foreach (var constructor in GridScriptConstructors)
try { constructor.Invoke(asGrid); }
catch (Exception ex)
{
myLogger.alwaysLog("Exception in grid constructor: " + ex, Logger.severity.ERROR);
Logger.debugNotify("Exception in grid constructor", 10000, Logger.severity.ERROR);
}
return;
}
IMyCharacter asCharacter = entity as IMyCharacter;
if (asCharacter != null)
{
if (!Characters.Add(entity.EntityId))
return;
entity.OnClosing += alsoChar => {
if (Characters != null)
Characters.Remove(alsoChar.EntityId);
};
myLogger.debugLog("adding character: " + entity.getBestName());
foreach (var constructor in CharacterScriptConstructors)
try { constructor.Invoke(asCharacter); }
catch (Exception ex)
{
myLogger.alwaysLog("Exception in character constructor: " + ex, Logger.severity.ERROR);
Logger.debugNotify("Exception in character constructor", 10000, Logger.severity.ERROR);
}
return;
}
}
示例7: Explode
/// <summary>
/// Spawns a rock to explode the missile.
/// </summary>
/// <remarks>
/// Runs on separate thread. (sort-of)
/// </remarks>
private void Explode()
{
MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
if (MyEntity.Closed)
return;
m_stage = Stage.Terminated;
MyEntity.Physics.LinearVelocity = Vector3.Zero;
RemoveRock();
MyObjectBuilder_InventoryItem item = new MyObjectBuilder_InventoryItem() { Amount = 100, Content = new MyObjectBuilder_Ore() { SubtypeName = "Stone" } };
MyObjectBuilder_FloatingObject rockBuilder = new MyObjectBuilder_FloatingObject();
rockBuilder.Item = item;
rockBuilder.PersistentFlags = MyPersistentEntityFlags2.InScene;
rockBuilder.PositionAndOrientation = new MyPositionAndOrientation()
{
Position = MyEntity.GetPosition(),
Forward = (Vector3)MyEntity.WorldMatrix.Forward,
Up = (Vector3)MyEntity.WorldMatrix.Up
};
myRock = MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(rockBuilder);
myLogger.debugLog("created rock at " + MyEntity.GetPosition() + ", " + myRock.getBestName(), "Explode()");
}, myLogger);
}
示例8: Detach
private void Detach(IMyEntity obj)
{
myLogger.debugLog("closed object: " + obj.getBestName() + ")", "Detach()");
try
{ Detach(); }
catch (Exception ex)
{
myLogger.debugLog("Exception: " + ex, "Detach()", Logger.severity.ERROR);
Logger.debugNotify("Detach encountered an exception", 10000, Logger.severity.ERROR);
}
}
示例9: ProjectileIsThreat
private bool ProjectileIsThreat(IMyEntity projectile, TargetType tType)
{
if (projectile.Closed)
return false;
Vector3D projectilePosition = projectile.GetPosition();
BoundingSphereD ignoreArea = new BoundingSphereD(ProjectilePosition(), Options.TargetingRange / 10f);
if (ignoreArea.Contains(projectilePosition) == ContainmentType.Contains)
return false;
Vector3D weaponPosition = ProjectilePosition();
Vector3D nextPosition = projectilePosition + projectile.GetLinearVelocity() / 60f;
if (Vector3D.DistanceSquared(weaponPosition, nextPosition) < Vector3D.DistanceSquared(weaponPosition, projectilePosition))
{
myLogger.debugLog("projectile: " + projectile.getBestName() + ", is moving towards weapon. D0 = " + Vector3D.DistanceSquared(weaponPosition, nextPosition) + ", D1 = " + Vector3D.DistanceSquared(weaponPosition, projectilePosition), "ProjectileIsThreat()");
return true;
}
else
{
myLogger.debugLog("projectile: " + projectile.getBestName() + ", is moving away from weapon. D0 = " + Vector3D.DistanceSquared(weaponPosition, nextPosition) + ", D1 = " + Vector3D.DistanceSquared(weaponPosition, projectilePosition), "ProjectileIsThreat()");
return false;
}
}
示例10: AddTarget
/// <summary>
/// Adds a target to Available_Targets
/// </summary>
private void AddTarget(TargetType tType, IMyEntity target)
{
if (!Options.CanTargetType(tType))
return;
if (target.ToString().StartsWith("MyMissile"))
{
myLogger.debugLog("missile: " + target.getBestName() + ", type = " + tType + ", allowed targets = " + Options.CanTarget, "AddTarget()");
}
List<IMyEntity> list;
if (!Available_Targets.TryGetValue(tType, out list))
{
list = new List<IMyEntity>();
Available_Targets.Add(tType, list);
}
list.Add(target);
}
示例11: TargetingBase
public TargetingBase(IMyEntity entity, IMyCubeBlock controllingBlock)
{
if (entity == null)
throw new ArgumentNullException("entity");
if (controllingBlock == null)
throw new ArgumentNullException("controllingBlock");
myLogger = new Logger("TargetingBase", () => entity.getBestName());
MyEntity = entity;
CubeBlock = controllingBlock;
FuncBlock = controllingBlock as IMyFunctionalBlock;
myTarget = new NoTarget();
CurrentTarget = myTarget;
Options = new TargetingOptions();
entity.OnClose += obj => {
if (WeaponsTargetingProjectile != null)
CurrentTarget = null;
};
myLogger.debugLog("entity: " + MyEntity.getBestName() + ", block: " + CubeBlock.getBestName(), "TargetingBase()");
}
示例12: Orbiter
/// <summary>
/// Creates an Orbiter for a specific entity, fake orbit only.
/// Does not add itself to navSet.
/// </summary>
/// <param name="faceBlock">The block that will be faced towards the orbited entity</param>
/// <param name="entity">The entity to be orbited</param>
/// <param name="distance">The distance between the orbiter and the orbited entity</param>
/// <param name="name">What to call the orbited entity</param>
public Orbiter(Mover mover, AllNavigationSettings navSet, PseudoBlock faceBlock, IMyEntity entity, float distance, string name)
: base(mover, navSet)
{
this.m_logger = new Logger(GetType().Name, m_controlBlock.CubeBlock);
this.m_navBlock = faceBlock;
this.m_orbitEntity_name = name;
Altitude = distance;
OrbitEntity = entity;
CalcFakeOrbitSpeedForce();
m_logger.debugLog("Orbiting: " + OrbitEntity.getBestName(), Logger.severity.INFO);
}
示例13: Receiver
public Receiver(IMyEntity entity)
{
m_logger = new Logger("Receiver", () => entity.getBestName());
Entity = entity;
}
示例14: GuidedMissile
/// <summary>
/// Creates a missile with homing and target finding capabilities.
/// </summary>
public GuidedMissile(IMyEntity missile, IMyCubeBlock firedBy, TargetingOptions opt, Ammo ammo, LastSeen initialTarget = null)
: base(missile, firedBy)
{
myLogger = new Logger("GuidedMissile", () => missile.getBestName(), () => m_stage.ToString());
myAmmo = ammo;
myDescr = ammo.Description;
if (ammo.Description.HasAntenna)
myAntenna = new MissileAntenna(missile);
TryHard = true;
AllGuidedMissiles.Add(this);
AddMissileOwner(MyEntity, CubeBlock.OwnerId);
MyEntity.OnClose += MyEntity_OnClose;
accelerationPerUpdate = (myDescr.Acceleration + myAmmo.MissileDefinition.MissileAcceleration) / 60f;
addSpeedPerUpdate = myDescr.Acceleration / 60f;
Options = opt;
Options.TargetingRange = ammo.Description.TargetRange;
myTargetSeen = initialTarget;
myLogger.debugLog("Options: " + Options + ", initial target: " + (initialTarget == null ? "null" : initialTarget.Entity.getBestName()), "GuidedMissile()");
//myLogger.debugLog("AmmoDescription: \n" + MyAPIGateway.Utilities.SerializeToXML<Ammo.AmmoDescription>(myDescr), "GuidedMissile()");
}