Constructor library: Changed to search through all available knowledge and filter using an overloadable function.

The hammer will now only construct definitions that have the callback "IsHammerBuidable". This will exclude all C4D_Structure objects that are not buildings and can't be build in a meaningful way.
Also, with the carry heavy branch I want to test adhoc built lorries (lorries as construction sites). Sven suggested this.
qteditor
Clonkonaut 2016-06-18 19:45:45 +02:00
parent 19395b23ae
commit b6ca10d11a
22 changed files with 63 additions and 3 deletions

View File

@ -12,6 +12,8 @@ public func Construction()
return _inherited(...);
}
public func IsHammerBuildable() { return true; }
func Initialize()
{
return _inherited(...);

View File

@ -15,6 +15,12 @@ public func GetCarryTransform() { return Trans_Rotate(-90,1,0,0); }
public func IsTool() { return true; }
public func IsToolProduct() { return true; }
func CanBuild(id construction_plan)
{
if (!construction_plan) return false;
if (construction_plan->~IsHammerBuildable()) return true;
return false;
}
/*-- Properties --*/

View File

@ -41,11 +41,26 @@ public func GetConstructionPlans(int plr)
{
var construction_plans = [];
var construct_id, index = 0;
while (construct_id = GetPlrKnowledge(plr, nil, index++, C4D_Structure))
construction_plans[index-1] = construct_id;
while (construct_id = GetPlrKnowledge(plr, nil, index++, C4D_Structure)) // Structures
if (CanBuild(construct_id))
construction_plans[GetLength(construction_plans)] = construct_id;
index = 0;
while (construct_id = GetPlrKnowledge(plr, nil, index++, C4D_Vehicle)) // Vehicles
if (CanBuild(construct_id))
construction_plans[GetLength(construction_plans)] = construct_id;
index = 0;
while (construct_id = GetPlrKnowledge(plr, nil, index++, C4D_Object)) // Objects
if (CanBuild(construct_id))
construction_plans[GetLength(construction_plans)] = construct_id;
return construction_plans;
}
// Checks whether a certain construction plans can be built by this constructor.
// Overload as seem fit.
func CanBuild(id construction_plan)
{
return true;
}
/*-- Construction preview --*/

View File

@ -16,6 +16,8 @@ func Construction(object creator)
return _inherited(creator, ...);
}
public func IsHammerBuildable() { return true; }
/*-- Production --*/
public func IsProduct(id product_id)

View File

@ -17,6 +17,8 @@ protected func Construction()
return _inherited(...);
}
public func IsHammerBuildable() { return true; }
protected func Initialize()
{
var wdt = GetObjWidth();

View File

@ -15,6 +15,8 @@ func Construction(object creator)
return _inherited(creator, ...);
}
public func IsHammerBuildable() { return true; }
/*-- Production --*/
public func IsProduct(id product_id)

View File

@ -22,6 +22,8 @@ protected func Construction()
return _inherited(...);
}
public func IsHammerBuildable() { return true; }
/*-- Contents --*/
public func IsContainer() { return true; }

View File

@ -30,6 +30,8 @@ protected func Construction(object creator)
return _inherited(creator, ...);
}
public func IsHammerBuildable() { return true; }
protected func Initialize()
{
leftcharge = CreateObjectAbove(Compensator_ChargeShower, 7 * GetCalcDir(), 10, NO_OWNER);

View File

@ -78,6 +78,8 @@ private func Construction()
return _inherited(...);
}
public func IsHammerBuildable() { return true; }
private func Initialize()
{
SetCategory(C4D_StaticBack);

View File

@ -33,6 +33,8 @@ protected func Construction()
return _inherited(...);
}
public func IsHammerBuildable() { return true; }
public func NoConstructionFlip() { return true; }
/*-- Interaction --*/

View File

@ -26,6 +26,8 @@ public func Construction(object creator)
return _inherited(creator, ...);
}
public func IsHammerBuildable() { return true; }
/*-- Production --*/
private func IgnoreKnowledge() { return true; }

View File

@ -6,4 +6,6 @@ local Description = "$Description$";
local Touchable = 1;
local Components = {GoldBar = 3};
public func IsHammerBuildable() { return true; }
public func NoConstructionFlip() { return true; }

View File

@ -15,6 +15,8 @@ func Construction(object creator)
return _inherited(creator, ...);
}
public func IsHammerBuildable() { return true; }
/*-- Production --*/
public func IsProduct(id product_id)

View File

@ -15,6 +15,8 @@ func Construction(object creator)
return _inherited(creator, ...);
}
public func IsHammerBuildable() { return true; }
/*-- Production --*/
func IsProduct(id product_id)

View File

@ -22,6 +22,8 @@ func Construction(object creator)
return _inherited(creator, ...);
}
public func IsHammerBuildable() { return true; }
/*-- Production --*/
public func IsProduct(id product_id)

View File

@ -48,6 +48,8 @@ func Construction()
return _inherited(...);
}
public func IsHammerBuildable() { return true; }
func Initialize()
{
switched_on = true;

View File

@ -19,6 +19,8 @@ public func Construction()
return _inherited(...);
}
public func IsHammerBuildable() { return true; }
public func Initialize()
{
this.SpinAnimation = PlayAnimation("work", 10, Anim_Const(0));

View File

@ -22,6 +22,8 @@ func Construction(object creator)
return _inherited(creator, ...);
}
public func IsHammerBuildable() { return true; }
/*-- Production --*/
public func IsProduct(id product_id)

View File

@ -27,8 +27,9 @@ protected func Initialize()
return _inherited(...);
}
public func IsContainer() { return true; }
public func IsHammerBuildable() { return true; }
public func IsContainer() { return true; }
protected func RejectCollect(id item, object obj)
{

View File

@ -15,6 +15,8 @@ public func Construction(object creator)
return _inherited(creator, ...);
}
public func IsHammerBuildable() { return true; }
public func Initialize()
{
hold_production = false;

View File

@ -31,6 +31,8 @@ protected func Construction()
return;
}
public func IsHammerBuildable() { return true; }
protected func Initialize()
{
// First initialize the libraries (especially the flag library).

View File

@ -24,6 +24,8 @@ protected func Construction()
return _inherited(...);
}
public func IsHammerBuildable() { return true; }
protected func Initialize()
{
// Create a helper object for the wheel.